Easy fix proposed by the submitter of Bug 32896 - Invalid endsWith function
Description:
The function endsWith in standard library returns false when the searched
substring is contained twice in string.
Example : fn:endsWith( 'abcdb' ,'b' ) returns false.
The fix is simple and proposed by the submitter of the bug Rastislav Rehak
<[EMAIL PROTECTED]>
The change is required in:
org/apache/taglibs/standard/functions/Functions.java
Thanks,
-Dhiru
Index: Functions.java
===================================================================
RCS file:
/home/cvspublic/jakarta-taglibs/standard/src/org/apache/taglibs/standard/functions/Functions.java,v
retrieving revision 1.9
diff -c -r1.9 Functions.java
*** Functions.java 16 Aug 2004 21:38:28 -0000 1.9
--- Functions.java 26 Jan 2005 00:57:51 -0000
***************
*** 83,89 ****
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());
--- 83,89 ----
public static boolean endsWith(String input, String substring) {
if (input == null) input = "";
if (substring == null) substring = "";
! int index = input.lastIndexOf(substring);
if (index == -1) return false;
if (index == 0 && substring.length() == 0) return true;
return (index == input.length() - substring.length());
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]