geratorres commented on a change in pull request #381: LANG-1406
StringIndexOutOfBoundsException in StringUtils.replaceIgnor…
URL: https://github.com/apache/commons-lang/pull/381#discussion_r283624717
##########
File path: src/main/java/org/apache/commons/lang3/StringUtils.java
##########
@@ -5596,7 +5596,16 @@ private static String replace(final String text, String
searchString, final Stri
}
String searchText = text;
if (ignoreCase) {
- searchText = text.toLowerCase();
+ StringBuilder buf = new StringBuilder(text.length());
+ for (int i = 0; i < text.length(); i++) {
+ char c = text.charAt(i);
+ if (Character.UnicodeBlock.of(c) !=
Character.UnicodeBlock.BASIC_LATIN) {
+ buf.append(c);
+ } else {
+ buf.append(Character.toLowerCase(c));
+ }
+ }
+ searchText = buf.toString();
searchString = searchString.toLowerCase();
Review comment:
searchString could contain one of those characters like "\u0130"
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services