Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[json-lib] applied patch 1976839

  • Loading branch information...
commit a6d94b8b28991b4c33f411b2e20c687d103518ae 1 parent 3597427
aalmiray authored
View
2  .cvsignore
@@ -6,3 +6,5 @@ build.properties
.project
.settings
.jruby
+build.sh
+build
View
1  pom.xml
@@ -317,7 +317,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
- <version>2.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
View
6 src/changes/changes.xml
@@ -15,6 +15,12 @@
<action
dev="Andres Almiray"
type="fix"
+ issue="1976839">
+ Performace patch in JSONUtil. Thanks to Ales Novy (provided a patch)
+ </action>
+ <action
+ dev="Andres Almiray"
+ type="fix"
issue="1955163">
Json-lib cannot parse functions with more than one argument
</action>
View
5 src/main/java/net/sf/json/util/JSONUtils.java
@@ -61,6 +61,7 @@
private static RegexpMatcher FUNCTION_PARAMS_MATCHER;
private static final String FUNCTION_PARAMS_PATTERN = "^function[ ]?\\((.*?)\\).*";
private static final String FUNCTION_PATTERN = "^function[ ]?\\(.*?\\)[ \n\t]*\\{.*?\\}$";
+ private static final String FUNCTION_PREFIX = "function";
private static final MorpherRegistry morpherRegistry = new MorpherRegistry();
@@ -285,7 +286,7 @@ public static boolean isDouble( Class clazz ) {
public static boolean isFunction( Object obj ) {
if( obj instanceof String ){
String str = (String) obj;
- return FUNCTION_MACTHER.matches( str );
+ return str.startsWith( FUNCTION_PREFIX ) && FUNCTION_MACTHER.matches( str );
}
if( obj instanceof JSONFunction ){
return true;
@@ -300,7 +301,7 @@ public static boolean isFunction( Object obj ) {
public static boolean isFunctionHeader( Object obj ) {
if( obj instanceof String ){
String str = (String) obj;
- return FUNCTION_HEADER_MATCHER.matches( str );
+ return str.startsWith( FUNCTION_PREFIX ) && FUNCTION_HEADER_MATCHER.matches( str );
}
return false;
}
View
11 src/test/java/net/sf/json/TestUserSubmitted.java
@@ -31,6 +31,7 @@
import net.sf.json.sample.BeanA1763699;
import net.sf.json.sample.BeanB1763699;
import net.sf.json.sample.BeanC;
+import net.sf.json.sample.ChildBean;
import net.sf.json.sample.DateBean;
import net.sf.json.sample.IdBean;
import net.sf.json.sample.InterfaceBean;
@@ -42,6 +43,7 @@
import net.sf.json.sample.MediaListBean;
import net.sf.json.sample.NumberArrayBean;
import net.sf.json.sample.PackageProtectedBean;
+import net.sf.json.sample.ParentBean;
import net.sf.json.sample.Player;
import net.sf.json.sample.PlayerList;
import net.sf.json.sample.PrimitiveBean;
@@ -545,6 +547,15 @@ public void testToBeanWithInterfaceField() {
assertNotNull( bean.getRunnable() );
assertTrue( bean.getRunnable() instanceof RunnableImpl );
}
+
+ public void testCycleDetection_withExclusions() {
+ ParentBean parent = new ParentBean();
+ parent.setChild( new ChildBean() );
+
+ // will fail if throws an exception
+ jsonConfig.setExcludes( new String[] { "parent" } );
+ JSONObject.fromObject( parent, jsonConfig );
+ }
public static class RunnableImpl implements Runnable {
public void run() {
Please sign in to comment.
Something went wrong with that request. Please try again.