Bug 48848 - fn:endsWith fails with repeated search string
Summary: fn:endsWith fails with repeated search string
Status: RESOLVED DUPLICATE of bug 32896
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: 1.1
Hardware: All All
: P2 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-03 10:41 UTC by Jose Miguel Samper
Modified: 2010-03-22 01:29 UTC (History)
0 users



Attachments
JSP which reproduces bug (193 bytes, text/plain)
2010-03-07 13:34 UTC, Jose Miguel Samper
Details
Simpler JSP which reproduces the bug (189 bytes, text/plain)
2010-03-07 13:59 UTC, Jose Miguel Samper
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jose Miguel Samper 2010-03-03 10:41:52 UTC
${fn:endsWith('$21', '1')} returns true, but
${fn:endsWith('$22', '2')} returns false.

Both comparisons should return true.

Standard taglib version is 1.1.2.

Tested on Tomcat 6.0.18 and Glassfish v3.
Comment 1 Jose Miguel Samper 2010-03-07 13:34:16 UTC
Created attachment 25101 [details]
JSP which reproduces bug

Drop JSP into web application to see the bug.

Of course, you need standard-taglibs in the classpath.
Comment 2 Konstantin Kolinko 2010-03-07 13:44:26 UTC
Wow! Indeed, broken. Can reproduce it with 6.0.24.

In org\apache\taglibs\standard\functions\Functions.java:
    public static boolean endsWith(String input, String substring) {
        if (input == null) input = "";
        if (substring == null) substring = "";
        int index = input.indexOf(substring);
        if (index == -1) return false;
        if (index == 0 && substring.length() == 0) return true;
        return (index == input.length() - substring.length());
    }  
there must be
        int index = input.lastIndexOf(substring);

though I more wonder why it does not just use
  String.endsWith(String)
like fn:startsWith already does.
Comment 3 Jose Miguel Samper 2010-03-07 13:59:47 UTC
Created attachment 25102 [details]
Simpler JSP which reproduces the bug

The bug has nothing to do with dollar sign, so I change the testcase.
Comment 4 Jose Miguel Samper 2010-03-07 14:00:45 UTC
The bug has nothing to do with dollar sign, so I changed the bug summary.
Comment 5 Jose Miguel Samper 2010-03-08 08:45:04 UTC
This bug is the same as bug #32896 

Bug #32896 was fixed in 2005!!! but standard-taglibs project has not released any version since 2004.
Comment 6 Henri Yandell 2010-03-22 01:29:43 UTC

*** This bug has been marked as a duplicate of bug 32896 ***