Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Newlines being inserted into strings #256

Open
Samccull-Bunnings opened this issue Dec 7, 2023 · 5 comments
Open

Newlines being inserted into strings #256

Samccull-Bunnings opened this issue Dec 7, 2023 · 5 comments
Labels
bug Something isn't working needs new SQLDev version

Comments

@Samccull-Bunnings
Copy link

when formatting files, newline characters get inserted into hardcoded strings containing encoded characters which can affect code logic

E.G. '</' becomes
'<
/'

@PhilippSalvisberg PhilippSalvisberg self-assigned this Dec 7, 2023
@PhilippSalvisberg PhilippSalvisberg added the bug Something isn't working label Dec 7, 2023
@PhilippSalvisberg
Copy link
Collaborator

I can reproduce it with

begin
   dbms_output.put_line('</');
end;
/

Formatter result is

begin
   dbms_output.put_line('<
/');
end;
/

This is a bug. Thank you for reporting it.

@PhilippSalvisberg
Copy link
Collaborator

PhilippSalvisberg commented Dec 9, 2023

The problem is not related to the Arbori program in this repo. In fact, the problem can be reproduced with the standard SQL Developer Arbori program.

The culprit code section at the end of the format method of the oracle.dbtools.app.Format class looks like this (decompiled with IntelliJ based on the JAR distributed with SQLcl 23.1):

                int index = -1;

                while(true) {
                    index = ret.indexOf(";/", index + 1);
                    if (index < 0) {
                        this.inputPos = -1;
                        return ret;
                    }

                    if (ret.indexOf("*", index + 1) != index + 2) {
                        String var10000 = ret.substring(0, index);
                        ret = var10000 + ";\n/" + ret.substring(index + 2);
                    }
                }
            }

The problem is also reproducible with the latest SQLcl 23.3:

image

PhilippSalvisberg added a commit that referenced this issue Dec 9, 2023
Issue is caused by SQLDev 23.1, SQLcl 23.3.
We cannot fix it in the Arbori code.
Therefore the tests are disabled for the time being.
PhilippSalvisberg added a commit that referenced this issue Dec 9, 2023
@PhilippSalvisberg
Copy link
Collaborator

Post in SQL Developer forum: https://forums.oracle.com/ords/apexds/post/sqldev-23-1-sqlcl-23-3-bug-formatter-breaks-code-when-strin-2775

@PhilippSalvisberg
Copy link
Collaborator

Issue is not fixed in SQLcl 23.4.0

@PhilippSalvisberg PhilippSalvisberg removed their assignment Apr 10, 2024
@WayneNani
Copy link

Issue is fixed in SQLcl 24.1.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working needs new SQLDev version
Projects
None yet
Development

No branches or pull requests

3 participants