Copilot commented on code in PR #2579:
URL: https://github.com/apache/groovy/pull/2579#discussion_r3330077342


##########
subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java:
##########
@@ -4688,7 +4689,7 @@ protected String nullify(String sql) {
      * @return the index of the found keyword or -1 if not found
      */
     protected int findWhereKeyword(String sql) {
-        char[] chars = sql.toLowerCase().toCharArray();
+        char[] chars = sql.toLowerCase(Locale.ROOT).toCharArray();

Review Comment:
   Lowercasing the whole SQL string can change its length for some Unicode 
characters (for example U+0130 lowercases to two code points under 
Locale.ROOT). Because this method returns an index that is later applied to the 
original SQL string, a non-ASCII identifier before `WHERE` can produce an 
incorrect offset and break `nullify`'s replacements. Compare characters 
case-insensitively without creating a lowercased copy so indices stay aligned 
with the original SQL.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to