解决办法:The request was rejected be

2020-04-25  本文已影响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;

    }

}

上一篇 下一篇

猜你喜欢

热点阅读