Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.help.webapp')
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/AboutParser.java4
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/NavParser.java4
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java8
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java6
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/JSonHelper.java12
5 files changed, 20 insertions, 14 deletions
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/AboutParser.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/AboutParser.java
index d0c21f958..d24570b07 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/AboutParser.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/AboutParser.java
@@ -102,13 +102,13 @@ public class AboutParser extends ResultParser {
buf.append(JSonHelper.BEGIN_BRACE);
buf.append(JSonHelper.NEWLINE + JSonHelper.SPACE);
- buf.append(JSonHelper.IDENTIFIER);
+ buf.append(JSonHelper.getQuotes(JSonHelper.IDENTIFIER));
buf.append(JSonHelper.COLON);
buf.append(JSonHelper.getQuotes(id));
buf.append(JSonHelper.COMMA);
buf.append(JSonHelper.NEWLINE + JSonHelper.SPACE);
- buf.append(JSonHelper.LABEL);
+ buf.append(JSonHelper.getQuotes(JSonHelper.LABEL));
buf.append(JSonHelper.COLON);
buf.append(JSonHelper.getQuotes(label));
buf.append(JSonHelper.COMMA);
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/NavParser.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/NavParser.java
index 0dcab04e8..c1446fa65 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/NavParser.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/NavParser.java
@@ -60,13 +60,13 @@ public class NavParser extends ResultParser {
buf.append(JSonHelper.BEGIN_BRACE);
buf.append(JSonHelper.NEWLINE + JSonHelper.SPACE);
- buf.append(JSonHelper.IDENTIFIER);
+ buf.append(JSonHelper.getQuotes(JSonHelper.IDENTIFIER));
buf.append(JSonHelper.COLON);
buf.append(JSonHelper.getQuotes(id));
buf.append(JSonHelper.COMMA);
buf.append(JSonHelper.NEWLINE + JSonHelper.SPACE);
- buf.append(JSonHelper.LABEL);
+ buf.append(JSonHelper.getQuotes(JSonHelper.LABEL));
buf.append(JSonHelper.COLON);
buf.append(JSonHelper.getQuotes(label));
buf.append(JSonHelper.COMMA);
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java
index 2e72fca8b..909d3839a 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ParseElement.java
@@ -82,7 +82,7 @@ public class ParseElement {
String val = props.getProperty(key);
buff.append(JSonHelper.NEWLINE + space + JSonHelper.SPACE);
- buff.append(key);
+ buff.append(JSonHelper.getQuotes(key));
buff.append(JSonHelper.COLON);
try {
val = URLEncoder.encode(val, "UTF-8"); //$NON-NLS-1$
@@ -105,7 +105,7 @@ public class ParseElement {
} else {
buff.append(JSonHelper.NEWLINE + space + JSonHelper.SPACE);
- buff.append(JSonHelper.CHILDREN);
+ buff.append(JSonHelper.getQuotes(JSonHelper.CHILDREN));
buff.append(JSonHelper.COLON);
buff.append(JSonHelper.BEGIN_BRACKET);
@@ -141,7 +141,7 @@ public class ParseElement {
String val = props.getProperty(key);
buff.append(JSonHelper.NEWLINE + JSonHelper.SPACE);
- buff.append(key);
+ buff.append(JSonHelper.getQuotes(key));
buff.append(JSonHelper.COLON);
try {
val = URLEncoder.encode(val, "UTF-8"); //$NON-NLS-1$
@@ -164,7 +164,7 @@ public class ParseElement {
} else {
buff.append(JSonHelper.NEWLINE + JSonHelper.SPACE);
- buff.append(JSonHelper.ITEMS);
+ buff.append(JSonHelper.getQuotes(JSonHelper.ITEMS));
buff.append(JSonHelper.COLON);
buff.append(JSonHelper.BEGIN_BRACKET);
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java
index 48c905c6d..cd3829553 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/parser/ResultParser.java
@@ -77,19 +77,19 @@ public class ResultParser extends DefaultHandler {
buf.append(JSonHelper.BEGIN_BRACE);
buf.append(JSonHelper.NEWLINE + JSonHelper.SPACE);
- buf.append(JSonHelper.IDENTIFIER);
+ buf.append(JSonHelper.getQuotes(JSonHelper.IDENTIFIER));
buf.append(JSonHelper.COLON);
buf.append(JSonHelper.getQuotes(id));
buf.append(JSonHelper.COMMA);
buf.append(JSonHelper.NEWLINE + JSonHelper.SPACE);
- buf.append(JSonHelper.LABEL);
+ buf.append(JSonHelper.getQuotes(JSonHelper.LABEL));
buf.append(JSonHelper.COLON);
buf.append(JSonHelper.getQuotes(label));
buf.append(JSonHelper.COMMA);
buf.append(JSonHelper.NEWLINE + JSonHelper.SPACE);
- buf.append(JSonHelper.ITEMS);
+ buf.append(JSonHelper.getQuotes(JSonHelper.ITEMS));
buf.append(JSonHelper.COLON);
buf.append(JSonHelper.BEGIN_BRACKET);
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/JSonHelper.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/JSonHelper.java
index 225573048..1043d559f 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/JSonHelper.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/JSonHelper.java
@@ -15,7 +15,7 @@ public final class JSonHelper {
//JSON Characters
public static final String BEGIN_BRACE = "{"; //$NON-NLS-1$
public static final String END_BRACE = "}"; //$NON-NLS-1$
- public static final String QUOTE = "\'"; //$NON-NLS-1$
+ public static final String DOUBLEQUOTE = "\""; //$NON-NLS-1$
public static final String COLON = ":"; //$NON-NLS-1$
public static final String BEGIN_BRACKET = "["; //$NON-NLS-1$
public static final String END_BRACKET = "]"; //$NON-NLS-1$
@@ -52,8 +52,14 @@ public final class JSonHelper {
public static final String TOPIC = "Topic"; //$NON-NLS-1$
public static final String NUMERIC_PATH = "NumericPath"; //$NON-NLS-1$
- public static String getQuotes(String str){
- return ((str != null)?QUOTE + str + QUOTE:""); //$NON-NLS-1$
+ public static String getQuotes(String str) {
+ if (str == null) {
+ return ""; //$NON-NLS-1$
+ }
+ if (str.indexOf(DOUBLEQUOTE) < 0) {
+ return DOUBLEQUOTE + str + DOUBLEQUOTE;
+ }
+ return DOUBLEQUOTE + str.replaceAll(DOUBLEQUOTE, "\\\\" + DOUBLEQUOTE) + DOUBLEQUOTE; //$NON-NLS-1$
}
}

Back to the top