}
/**
* 覆盖getHeader方法,将参数名和参数值都做xss过滤 。
* 如果需要获得原始的值,则通过super.getHeaders(name)来获取
* getHeaderNames 也可能需要覆盖
*/
@Override
public String getHeader(String name) {
String value = https://www.isolves.com/it/cxkf/yy/php/2019-10-14/super.getHeader(name);
if (value =https://www.isolves.com/it/cxkf/yy/php/2019-10-14/= null) {
return null;
}
return cleanXSS(value);
}
private String cleanXSS(String valueP) {
// You'll need to remove the spaces from the html entities below
String value = https://www.isolves.com/it/cxkf/yy/php/2019-10-14/valueP.replaceAll("<", "<").replaceAll(">", ">");
value = https://www.isolves.com/it/cxkf/yy/php/2019-10-14/value.replaceAll("<", "& lt;").replaceAll(">", "& gt;");
value = https://www.isolves.com/it/cxkf/yy/php/2019-10-14/value.replaceAll("/(", "& #40;").replaceAll("/)", "& #41;");
value = https://www.isolves.com/it/cxkf/yy/php/2019-10-14/value.replaceAll("'", "& #39;");
value = https://www.isolves.com/it/cxkf/yy/php/2019-10-14/value.replaceAll("eval/((.*)/)", "");
value = value.replaceAll("[\"\'][\s]*JavaScript:(.*)[\"\']", """");
value = https://www.isolves.com/it/cxkf/yy/php/2019-10-14/value.replaceAll("script", "");
value = https://www.isolves.com/it/cxkf/yy/php/2019-10-14/cleanSqlKeyWords(value);
return value;
}
private String cleanSqlKeyWords(String value) {
String paramValue = https://www.isolves.com/it/cxkf/yy/php/2019-10-14/value;
for (String keyword : notAllowedKeyWords) {
if (paramValue.length() > keyword.length() + 4
&& (paramValue.contains(" "+keyword)||paramValue.contains(keyword+" ")||paramValue.
contains(" "+keyword+" "))) {
paramValue = https://www.isolves.com/it/cxkf/yy/php/2019-10-14/StringUtils.replace(paramValue, keyword, replacedString);
log.error(this.currentUrl + "已被过滤,因为参数中包含不允许sql的关键词(" + keyword
+ ")"+";参数:"+value+";过滤后的参数:"+paramValue);
}
}
return paramValue;
}
}
以上就是thinkphp如何防止sql注入xss攻击的详细内容,更多请关注其它相关文章!
推荐阅读
- HTTPS性能优化原理与实践——如何优化HTTPS
- Oracle数据库之如何快速查找未使用绑定变量的SQL语句
- 宝宝不吸乳头如何处理
- 为何淘宝违规商品举报不了 淘宝上如何投诉侵权
- 更年期女性如何喝茶更健康
- 为什么喉咙痛完第二天就感冒,如何判断得了什么类型的感冒
- 如何区别春茶与夏秋茶 你会吗
- 中国茶的历史,陆羽如何将儒释道精神融合入茶经
- 穷人如何幸福? 穷人的幸福
- 如何写劳动仲裁申请?快,纯干货,你可能暂不需要,但先收藏