美文网首页
解决办法:The request was rejected be

解决办法:The request was rejected be

作者: 何佳阳 | 来源:发表于2020-04-25 14:42 被阅读0次

遇到这个问题是因为url里面多了一个/ ,  例如:http://aaa.ccc/b//cc,解决办法:去掉url内多余斜杠。

因为Spring Security 在高版本中增加了StrictHttpFirewall类,对URL校验更加严格

privatestaticbooleanisNormalized(String path){

    if (path == null) {

        return true;

    } else if (path.indexOf("//") > -1) {

        return false;

    } else {

        int i;

        for(int j = path.length(); j > 0; j = i) {

            i = path.lastIndexOf(47, j - 1);

            int gap = j - i;

            if (gap == 2 && path.charAt(i + 1) == '.') {

                return false;

            }

            if (gap == 3 && path.charAt(i + 1) == '.' && path.charAt(i + 2) == '.') {

                return false;

            }

        }

        return true;

    }

}

相关文章

网友评论

      本文标题:解决办法:The request was rejected be

      本文链接:https://www.haomeiwen.com/subject/kbckwhtx.html