commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmi...@apache.org
Subject svn commit: r387363 - in /jakarta/commons/proper/jxpath/trunk/src: java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java
Date Tue, 21 Mar 2006 00:48:07 GMT
Author: dmitri
Date: Mon Mar 20 16:48:07 2006
New Revision: 387363

URL: http://svn.apache.org/viewcvs?rev=387363&view=rev
Log:
Fixed a problem caused by "from" index greater than the string
s length.  Thanks to Barzilai Spinak

Modified:
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java
    jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java?rev=387363&r1=387362&r2=387363&view=diff
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java
(original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java
Mon Mar 20 16:48:07 2006
@@ -473,6 +473,9 @@
         }
 
         from = Math.round(from);
+        if (from > s1.length() + 1) {
+            return "";
+        }
         if (ac == 2) {
             if (from < 1) {
                 from = 1;

Modified: jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java?rev=387363&r1=387362&r2=387363&view=diff
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java
(original)
+++ jakarta/commons/proper/jxpath/trunk/src/test/org/apache/commons/jxpath/ri/compiler/CoreFunctionTest.java
Mon Mar 20 16:48:07 2006
@@ -82,6 +82,9 @@
         assertXPathValue(context, "substring('12345', 1, 0 div 0)", "");
         assertXPathValue(context, "substring('12345', -42, 1 div 0)", "12345");
         assertXPathValue(context, "substring('12345', -1 div 0, 1 div 0)", "");
+        assertXPathValue(context, "substring('12345', 6, 6)", "");
+        assertXPathValue(context, "substring('12345', 7, 8)", "");
+        assertXPathValue(context, "substring('12345', 7)", "");
         assertXPathValue(context, "string-length('12345')", new Double(5));
         assertXPathValue(context, "normalize-space(' abc  def  ')", "abc def");
         assertXPathValue(context, "normalize-space('abc def')", "abc def");



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message