asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject asterixdb git commit: fix escaping of strings in JSON values
Date Wed, 12 Oct 2016 22:52:47 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 6f1c55962 -> 8ee7d1d90


fix escaping of strings in JSON values

Change-Id: If68c1c4606501dbd205e67d6a73f4086a8f0b793
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1271
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/8ee7d1d9
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/8ee7d1d9
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/8ee7d1d9

Branch: refs/heads/master
Commit: 8ee7d1d906665cca85a00db02fb942cbc8548964
Parents: 6f1c559
Author: Till Westmann <tillw@apache.org>
Authored: Wed Oct 12 14:07:18 2016 -0700
Committer: Yingyi Bu <buyingyi@gmail.com>
Committed: Wed Oct 12 15:46:48 2016 -0700

----------------------------------------------------------------------
 .../java/org/apache/asterix/common/utils/JSONUtil.java   | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ee7d1d9/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/JSONUtil.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/JSONUtil.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/JSONUtil.java
index fd89c5e..0cbf1b9 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/JSONUtil.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/JSONUtil.java
@@ -49,7 +49,7 @@ public class JSONUtil {
         } else if (o instanceof JSONArray) {
             return append(sb, (JSONArray) o, indent);
         } else if (o instanceof String) {
-            return quote(sb, (String) o);
+            return quoteAndEscape(sb, (String) o);
         } else if (JSONObject.NULL.equals(o) || o instanceof Number || o instanceof Boolean)
{
             return sb.append(String.valueOf(o));
         }
@@ -102,10 +102,11 @@ public class JSONUtil {
     }
 
     public static String quoteAndEscape(String str) {
-        StringBuilder sb = new StringBuilder();
-        sb.append('"');
-        escape(sb, str);
-        return sb.append('"').toString();
+        return quoteAndEscape(new StringBuilder(), str).toString();
+    }
+
+    private static StringBuilder quoteAndEscape(StringBuilder sb, String str) {
+        return escape(sb.append('"'), str).append('"');
     }
 
     public static String escape(String str) {


Mime
View raw message