Patched the json lib to allow up to 100 levels of nesting.

Fixed ImportProjectCommand to redirect from the error page back to /index rather than /index.html.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@1270 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-09-17 00:21:54 +00:00
parent eee4514643
commit 8d1f2d44b9
4 changed files with 44 additions and 1 deletions

View File

@ -53,7 +53,7 @@ public class ImportProjectCommand extends Command {
redirect(response, "/project?project=" + projectID);
} else {
redirect(response, "/error.html?redirect=index.html&msg=" +
redirect(response, "/error.html?redirect=index&msg=" +
ParsingUtilities.encode("Failed to import project")
);
}

View File

@ -0,0 +1,43 @@
diff -rupN org/json/JSONWriter.java json/src/org/json/JSONWriter.java
--- org/json/JSONWriter.java 2010-01-30 15:13:38.000000000 -0800
+++ json/src/org/json/JSONWriter.java 2010-09-16 16:59:11.000000000 -0700
@@ -57,7 +57,7 @@ SOFTWARE.
* @version 2008-09-22
*/
public class JSONWriter {
- private static final int maxdepth = 20;
+ private static final int maxdepth = 100;
/**
* The comma flag determines if a comma should be output before the next
@@ -91,12 +91,19 @@ public class JSONWriter {
protected Writer writer;
/**
- * Make a fresh JSONWriter. It can be used to build one JSON text.
+ * Make a fresh JSONWriter at the default maximum depth. It can be used to build one JSON text.
*/
public JSONWriter(Writer w) {
+ this(w, maxdepth);
+ }
+
+ /**
+ * Make a fresh JSONWriter at the given maximum depth. It can be used to build one JSON text.
+ */
+ public JSONWriter(Writer w, int depth) {
this.comma = false;
this.mode = 'i';
- this.stack = new JSONObject[maxdepth];
+ this.stack = new JSONObject[depth];
this.top = 0;
this.writer = w;
}
@@ -268,7 +275,7 @@ public class JSONWriter {
* @throws JSONException If nesting is too deep.
*/
private void push(JSONObject jo) throws JSONException {
- if (this.top >= maxdepth) {
+ if (this.top >= this.stack.length) {
throw new JSONException("Nesting too deep.");
}
this.stack[this.top] = jo;