com.github.qq275860560.common.util.XssUtil Maven / Gradle / Ivy
package com.github.qq275860560.common.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
/**
* @author [email protected]
* 仿照redis的语法建立的本地jvm缓存 *
*/
public class XssUtil {
public static String cleanXSS(String value) {
// logger.info("清除恶意的XSS脚本 before value="+value);
// 移除特殊标签
if (StringUtils.isNotEmpty(value)) {
value = value.replaceAll("<", "<").replaceAll(">", ">");
value = value.replaceAll("\\(", "(").replaceAll("\\)", ")");
value = value.replaceAll("'", "'");
value = value.replaceAll("[e|E][v|V][a|A][l|L]\\((.*)\\)", "");
value = value.replaceAll(
"[\\\"\\\'][\\s]*[j|J][a|A][v|V][a|A][s|S][c|C][r|R][i|I][p|P][t|T]:(.*)[\\\"\\\']", "\"\"");
value = value.replaceAll("[s|S][c|C][r|R][i|C][p|P][t|T]", "");
}
return value;
}
public static String delHTMLTag(String htmlStr) {
String regEx_script = " 员工数据 \t\t
// \t\t \t\t\t \t\t\t\t归属公司 \r\n 热线号码 \r\n 业务功能 \r\n 市府办 \r\n 22831628 \r\n";
// HtmlScriptUtils h=new HtmlScriptUtils();
//// str=h.cleanXSS(str);
//// System.out.println(str);
//
// str=h.delHTMLTag(str);
// System.out.println(str);
// 去除html转义
String content = "(家庭)e8天翼宽带套餐退订异常\n";
content = StringEscapeUtils.unescapeHtml(content);
System.out.println(content);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy