Commit f470a500 by s_guodong

修复快照中特殊字符的bug

parent 30b251f4
...@@ -697,9 +697,38 @@ public class SnapshotServiceImpl implements SnapshotService { ...@@ -697,9 +697,38 @@ public class SnapshotServiceImpl implements SnapshotService {
if (value instanceof Boolean) { if (value instanceof Boolean) {
value = String.valueOf(value); value = String.valueOf(value);
} }
value = String.valueOf(value).replaceAll("&", "&")
.replaceAll("<", "&lt;")
.replaceAll(">", "&gt;")
.replaceAll("\"", "&quot;")
.replaceAll("\'", "&apos;");
} }
return value; return value;
} }
private void characters(char[] ch, int start, int length) {
for (int i = start; i < start + length; i++) {
char c = ch[i];
switch (c) {
case '&':
characters("&amp;".toCharArray(), 0, 5);
break;
case '<':
characters("&lt;".toCharArray(), 0, 4);
break;
case '>':
characters("&gt;".toCharArray(), 0, 4);
break;
case '"':
characters("&quot;".toCharArray(), 0, 6);
break;
case '\'':
characters("&apos;".toCharArray(), 0, 6);
break;
}
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment