commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "HiuFung Kwok (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-1406) StringIndexOutOfBoundsException in StringUtils.replaceIgnoreCase
Date Sat, 15 Sep 2018 06:58:00 GMT

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

HiuFung Kwok commented on LANG-1406:
------------------------------------

Hi [~michaelryan]

I have try to implement your idea into the actual codebase against it. According to the theory
the out of bound exception should be fixed.
 As one to one mapping is performed during the .toLowerCase process. It's guaranteed to always
give back the same length of String in return.[Here|https://github.com/HiuKwok/commons-lang/commit/a998e3de65a59d0859157f99e6cdf99469aa009f] is
the commit btw.

However on certain situation seems would leads to mismatch, which I listed the fail case on
the same commit as well.

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

Mime
View raw message