commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r601523 - /commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java
Date Wed, 05 Dec 2007 21:04:20 GMT
Author: mbenson
Date: Wed Dec  5 13:04:15 2007
New Revision: 601523

URL: http://svn.apache.org/viewvc?rev=601523&view=rev
Log:
[JXPATH-104] filter out invalid property paths

Modified:
    commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java

Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java
URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java?rev=601523&r1=601522&r2=601523&view=diff
==============================================================================
--- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java
(original)
+++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java
Wed Dec  5 13:04:15 2007
@@ -183,6 +183,9 @@
         NodePointer childPointer =
             createChildPointerForStep(parentPointer, step);
 
+        if (childPointer == null) {
+            return null;
+        }
         if (!childPointer.isActual()) {
             // The property does not exist - create a null pointer.
             return createNullPointer(
@@ -308,18 +311,19 @@
     {
         int axis = step.getAxis();
         if (axis == Compiler.AXIS_CHILD || axis == Compiler.AXIS_ATTRIBUTE) {
-            NodePointer childPointer;
             QName name = ((NodeNameTest) step.getNodeTest()).getNodeName();
             if (axis == Compiler.AXIS_ATTRIBUTE && isLangAttribute(name)) {
-                childPointer = new LangAttributePointer(parentPointer);
+                return new LangAttributePointer(parentPointer);
             }
-            else {
-                childPointer = parentPointer.getPropertyPointer();
+            if (parentPointer.isValidProperty(name)) {
+                NodePointer childPointer = parentPointer.getPropertyPointer();
                 ((PropertyPointer) childPointer).setPropertyName(
-                    name.toString());
+                        name.toString());
                 childPointer.setAttribute(axis == Compiler.AXIS_ATTRIBUTE);
+                return childPointer;
             }
-            return childPointer;
+            //invalid property gets nothing, not even a NullPointer
+            return null;
         }
         return parentPointer;
     }



Mime
View raw message