All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.lulihu.ObjectKit.WafKit Maven / Gradle / Ivy

package net.lulihu.ObjectKit;

import java.util.regex.Pattern;

/**
 * Web防火墙工具类
 */
public class WafKit {

    /**
     * 过滤XSS脚本内容
     *
     * @param value 待处理内容
     * @return 过滤后的字符串
     */
    public static String stripXSS(String value) {
        String rlt = null;

        if (null != value) {
            // 避免使用空字符
            rlt = value.replaceAll("", "");

            // 避免在脚本标记之间进行
            Pattern scriptPattern = Pattern.compile("", Pattern.CASE_INSENSITIVE);
            rlt = scriptPattern.matcher(rlt).replaceAll("");

            // 删除任何的标记
            scriptPattern = Pattern.compile("", Pattern.CASE_INSENSITIVE);
            rlt = scriptPattern.matcher(rlt).replaceAll("");

            // 删除任何的