[Swift-commit] r6104 - trunk/src/org/griphyn/vdl/engine
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Thu Dec 13 17:38:53 CST 2012
Author: hategan
Date: 2012-12-13 17:38:53 -0600 (Thu, 13 Dec 2012)
New Revision: 6104
Modified:
trunk/src/org/griphyn/vdl/engine/Karajan.java
Log:
escape "<", ">", and "&" in string literals when compiling
Modified: trunk/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/Karajan.java 2012-12-13 23:38:36 UTC (rev 6103)
+++ trunk/src/org/griphyn/vdl/engine/Karajan.java 2012-12-13 23:38:53 UTC (rev 6104)
@@ -1629,7 +1629,7 @@
for (String key : stringInternMap.keySet()) {
String variableName = stringInternMap.get(key);
StringTemplate st = template("sConst");
- st.setAttribute("innervalue",escapeQuotes(key));
+ st.setAttribute("innervalue",escapeQuotesAndMarkup(key));
StringTemplate vt = template("globalConstant");
vt.setAttribute("name",variableName);
vt.setAttribute("expr",st);
@@ -1661,6 +1661,30 @@
return in.replaceAll("\"", """);
}
+ String escapeQuotesAndMarkup(String in) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < in.length(); i++) {
+ char c = in.charAt(i);
+ switch (c) {
+ case '<':
+ sb.append("<");
+ break;
+ case '>':
+ sb.append(">");
+ break;
+ case '"':
+ sb.append(""");
+ break;
+ case '&':
+ sb.append("&");
+ break;
+ default:
+ sb.append(c);
+ }
+ }
+ return sb.toString();
+ }
+
public static String normalize(String type) {
return org.griphyn.vdl.type.Types.normalize(type);
}
More information about the Swift-commit
mailing list