[ 
https://issues.apache.org/jira/browse/GROOVY-12055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18084722#comment-18084722
 ] 

ASF GitHub Bot commented on GROOVY-12055:
-----------------------------------------

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.





> Assess toLower/UpperCase calls which should use Locale.ROOT
> -----------------------------------------------------------
>
>                 Key: GROOVY-12055
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12055
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Paul King
>            Priority: Major
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to