This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git

commit d68e2e9125126938399175f424f06301f497b920
Author: geratorres <gerator...@users.noreply.github.com>
AuthorDate: Wed Sep 11 09:12:53 2019 -0400

    [LANG-1406] StringIndexOutOfBoundsException in
    StringUtils.replaceIgnoreCase
    
    Closes #423.
---
 src/changes/changes.xml                                     | 5 +++--
 src/main/java/org/apache/commons/lang3/StringUtils.java     | 4 ++--
 src/test/java/org/apache/commons/lang3/StringUtilsTest.java | 3 +++
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 1a37c7c..0ed0db0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -64,8 +64,9 @@ The <action> type attribute can be add,update,fix,remove.
     <action issue="LANG-1475" type="fix" dev="kinow" 
due-to="stzx">StringUtils.unwrap incorrect throw 
StringIndexOutOfBoundsException.</action>
     <action issue="LANG-1485" type="add" dev="ggregory" due-to="nicolasbd">Add 
getters for lhs and rhs objects in DiffResult #451.</action>
     <action issue="LANG-1486" type="add" dev="ggregory" due-to="Gary 
Gregory">Generify builder classes Diffable, DiffBuilder, and DiffResult 
#452.</action>
-    <action issue="LANG-1487" type="add" dev="ggregory" due-to="Gary 
Gregory">Add ClassLoaderUtils with toString() implementations. #453.</action>
-    <action issue="LANG-1489" type="add" dev="ggregory" due-to="Gary 
Gregory">Add null-safe APIs as StringUtils.toRootLowerCase(String) and 
StringUtils.toRootUpperCase(String). #456.</action>
+    <action issue="LANG-1487" type="add" dev="ggregory" due-to="Gary 
Gregory">Add ClassLoaderUtils with toString() implementations #453.</action>
+    <action issue="LANG-1489" type="add" dev="ggregory" due-to="Gary 
Gregory">Add null-safe APIs as StringUtils.toRootLowerCase(String) and 
StringUtils.toRootUpperCase(String) #456.</action>
+    <action issue="LANG-1406" type="add" dev="ggregory" 
due-to="geratorres">StringIndexOutOfBoundsException in 
StringUtils.replaceIgnoreCase #423.</action>
   </release>
 
   <release version="3.9" date="2019-04-09" description="New features and bug 
fixes. Requires Java 8, supports Java 9, 10, 11.">
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java 
b/src/main/java/org/apache/commons/lang3/StringUtils.java
index 7741303..a2402b1 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -6369,7 +6369,7 @@ public class StringUtils {
              searchString = searchString.toLowerCase();
          }
          int start = 0;
-         int end = searchText.indexOf(searchString, start);
+         int end = ignoreCase ? indexOfIgnoreCase(text, searchString, start) : 
indexOf(text, searchString, start);
          if (end == INDEX_NOT_FOUND) {
              return text;
          }
@@ -6384,7 +6384,7 @@ public class StringUtils {
              if (--max == 0) {
                  break;
              }
-             end = searchText.indexOf(searchString, start);
+             end = ignoreCase ? indexOfIgnoreCase(text, searchString, start) : 
indexOf(text, searchString, start);
          }
          buf.append(text, start, text.length());
          return buf.toString();
diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java 
b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
index 7063fc8..29b368a 100644
--- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java
@@ -1684,6 +1684,9 @@ public class StringUtilsTest {
 
         // StringUtils.removeIgnoreCase("queued", "zZ") = "queued"
         assertEquals("queued", StringUtils.removeIgnoreCase("queued", "zZ"));
+        
+        // StringUtils.removeIgnoreCase("\u0130x", "x") = "\u0130"
+        assertEquals("\u0130", StringUtils.removeIgnoreCase("\u0130x", "x"));
     }
 
     @Test

Reply via email to