yuwei5380 / jsonplugin

Automatically exported from code.google.com/p/jsonplugin
0 stars 0 forks source link

IncludeProperties regex is incorrect #99

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
this is my regex in xml:
<param name="includeProperties">
    \[\d+\]\.[^.]*$,
    \[\d+\]\.children\[\d+\]\.catName
</param>
but the property [0].children[1].catName
is ignored.

It shouldn't be ignored based on the regex expression 
:\[\d+\]\.children\[\d+\]\.catName

Original issue reported on code.google.com by shanchun...@gmail.com on 13 Sep 2009 at 7:51

GoogleCodeExporter commented 8 years ago
The exception is:
Caused by: java.util.regex.PatternSyntaxException: Unexpected internal error 
near 
index 8
\[\d+\]\
        ^
    at java.util.regex.Pattern.error(Pattern.java:1713)
    at java.util.regex.Pattern.compile(Pattern.java:1466)
    at java.util.regex.Pattern.<init>(Pattern.java:1133)
    at java.util.regex.Pattern.compile(Pattern.java:823)
    at 
com.googlecode.jsonplugin.JSONResult.setIncludeProperties(JSONResult.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:517)
    at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:812)
    at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:964)
    at 
ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:75)
    at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:131)
    at 
com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.
java:
28)
    at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1656)
    at ognl.ASTProperty.setValueBody(ASTProperty.java:101)
    at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
    at ognl.SimpleNode.setValue(SimpleNode.java:246)
    at ognl.Ognl.setValue(Ognl.java:476)
    at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192)
    at 
com.opensymphony.xwork2.ognl.OgnlUtil.internalSetProperty(OgnlUtil.java:385)

Original comment by shanchun...@gmail.com on 14 Sep 2009 at 4:09

GoogleCodeExporter commented 8 years ago
seems a mistake in JSONResult.java
    if (patternPiece.endsWith("\\]")) {

this.includeProperties.add(Pattern.compile(patternExpr.substring(0, 
patternExpr.lastIndexOf("\\["))));

                            if (log.isDebugEnabled())
                                log.debug("Adding include property expression:  " + 
patternExpr.substring(0, patternPiece.lastIndexOf("\\[")));
                        }

should be:

     if (patternPiece.endsWith("\\]")) {

this.includeProperties.add(Pattern.compile(patternExpr.substring(0, 
patternExpr.lastIndexOf("\\["))));

                            if (log.isDebugEnabled())
                                log.debug("Adding include property expression:  " + 
patternExpr.substring(0, patternExpr.lastIndexOf("\\[")));
                        }

Original comment by shanchun...@gmail.com on 14 Sep 2009 at 4:58