Newlines being inserted into strings
Samccull-Bunnings opened this issue · 4 comments
when formatting files, newline characters get inserted into hardcoded strings containing encoded characters which can affect code logic
E.G. '</'
becomes
'<
/'
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.
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:
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
Issue is not fixed in SQLcl 23.4.0