我有一個JSP贖回XSS攻擊,在此檢查,如果內容的正則表達式匹配,以確定它是否是安全與否,這裏是代碼:爲什麼這個正則表達式顯示安全性?
String contents = bodyContent.getString();
String regExp = new String("^\\w{5,25}$");
// Do a regex to find the good stuff
if (contents.matches(regExp)) {
//write the original content
}else{
//change content to make it safe and write it
}
我的問題是關於正則表達式「^ \ w {5,25} $」,您可以在視覺上看到它here。爲何匹配這個正則表達式顯示安全性
不應該是^ \ w {5,25} $? – BonyT
*爲什麼匹配這個正則表達式顯示安全?* - 說什麼? – aioobe
@ BonyT-是的。你是對的 – Saeed