commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-1406) StringIndexOutOfBoundsException in StringUtils.replaceIgnoreCase
Date Tue, 14 Aug 2018 10:50:00 GMT

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

ASF GitHub Bot commented on LANG-1406:
--------------------------------------

Github user kinow commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/340#discussion_r209907553
  
    --- Diff: src/main/java/org/apache/commons/lang3/StringUtils.java ---
    @@ -5596,8 +5596,8 @@ private static String replace(final String text, String searchString,
final Stri
              }
              String searchText = text;
              if (ignoreCase) {
    -             searchText = text.toLowerCase();
    -             searchString = searchString.toLowerCase();
    +             searchText = text.toUpperCase();
    +             searchString = searchString.toUpperCase();
    --- End diff --
    
    Yeah, a very slippery problem. We still have the option to simply document that the method
does not work well with unicode strings. 
    
    But first I would like to spend at least a few hours with paper and pencil (and eraser,
because this could take a bit till I give up or find a possible way around it), and perhaps
even check in the mailing list if other devs have any idea.
    
    I think you found a very interesting problem (*)! Keep the ideas coming if you have any
on how to solve this issue :+1: 
    
    _* if I had more time, I would possibly either go through other methods checking for that
or, just try some fuzzifier approach to test the whole project ! Not aware of any static or
dynamic analysis tool that does that_


> 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