Skip to content

Commit e35f30e

Browse files
committed
add url whitelist vul code
1 parent 571e0c3 commit e35f30e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main/java/org/joychou/controller/URLWhiteList.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ public String regex(HttpServletRequest request) throws Exception{
7777
}
7878

7979

80+
@RequestMapping("/indexof")
81+
@ResponseBody
82+
public String indexOf(HttpServletRequest request) throws Exception{
83+
String url = request.getParameter("url");
84+
// indexof返回-1,表示没有匹配到字符串
85+
if (-1 == url.indexOf(urlwhitelist)) {
86+
return "URL is illegal";
87+
} else {
88+
return "URL is legal";
89+
}
90+
}
91+
8092
// 安全代码
8193
@RequestMapping("/seccode")
8294
@ResponseBody

0 commit comments

Comments
 (0)