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

Gerardo Torres Ontiveros edited comment on LANG-1406 at 5/14/19 8:58 PM:
-------------------------------------------------------------------------

I created another pull request 
[https://github.com/apache/commons-lang/pull/423] focused on resolving only 
this issue. In the method replace I removed the conversion of the text and 
searchString to lowercase, also instead of using text.indexOf() I put a ternary 
operator to use StringUtils.indexofIgnorecase if the ignoreCase flag is true 
otherwise is used StringUtils.indexOf. I think this is a good solution because 
replace now uses some methods already implemented on StringUtils, this commit 
removes the use of the second variable that makes some characters indexes were 
different.


was (Author: gtorres):
I created another pull request 
[https://github.com/apache/commons-lang/pull/423] focused on resolving only 
this issue. In the method replace I removed the conversion of the text and 
searchString to lowercase, also instead of using text.indexOf() I put a ternary 
operator to use StringUtils.indexofIgnorecase if the ignoreCase flag is true 
otherwise is used StringUtils.indexOf. I think this is a good solution because 
replace now uses some methods already implemented on StringUtils, this commit 
removes the use of the second variable that makes the indexes of some 
characters were calculated differently.

> StringIndexOutOfBoundsException in StringUtils.replaceIgnoreCase
> ----------------------------------------------------------------
>
>                 Key: LANG-1406
>                 URL: https://issues.apache.org/jira/browse/LANG-1406
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>            Reporter: Michael Ryan
>            Priority: Major
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> STEPS TO REPRODUCE:
> {code}
> StringUtils.replaceIgnoreCase("\u0130x", "x", "")
> {code}
> EXPECTED: "\u0130" is returned.
> ACTUAL: StringIndexOutOfBoundsException
> This happens because the replace method is assuming that text.length() == 
> text.toLowerCase().length(), which is not true for certain characters.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to