Till Westmann has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1271

Change subject: fix escaping of strings in JSON values
......................................................................

fix escaping of strings in JSON values

Change-Id: If68c1c4606501dbd205e67d6a73f4086a8f0b793
---
M 
asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/JSONUtil.java
1 file changed, 6 insertions(+), 5 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/71/1271/1

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 @@
         } 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 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) {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1271
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If68c1c4606501dbd205e67d6a73f4086a8f0b793
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Till Westmann <ti...@apache.org>

Reply via email to