So we need to "escape" these characters, find valid character to replace them.
/**
< -> < > -> > " -> " ' -> ' & -> &
**/
private String escape(String src) {
String result = new String(src.trim());
result = result.replaceAll("&", "&");
result = result.replaceAll("<", "<");
result = result.replaceAll(">", ">");
result = result.replaceAll("\"", """);
result = result.replaceAll("\'", "'");
return result;
}
没有评论:
发表评论