過濾敏感字符

    /**
     * 驗證有無敏感字符
     * @author heshuang
     * @date   20191224
     */
    public boolean checkParams(String param) {
        String reg = "(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|"
                + "(\\b(select|update|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute)\\b)";
        Pattern sqlPattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
        //String cFlag = "Y";
        if (sqlPattern.matcher(param).find()) {
            //cFlag = "N";
            return false;
        }
        return true;
    }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章