[LANG-1406] StringIndexOutOfBoundsException in

StringUtils.replaceIgnoreCase

Closes #423.
This commit is contained in:
geratorres 2019-09-11 09:12:53 -04:00 committed by Gary Gregory
parent 2af6e9aa58
commit d68e2e9125
3 changed files with 8 additions and 4 deletions

View File

@ -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.">

View File

@ -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();

View File

@ -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