Last active
October 14, 2015 16:12
-
-
Save syhily/160a57f6e0d43b348278 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.lang3.StringUtils; | |
import javax.servlet.http.HttpServletRequest; | |
/** | |
* 类名称:WebUtils <br> | |
* 类描述: <br> | |
* | |
* @author yufan.sheng | |
* @since 2014-4-27 上午10:11:49 | |
* @version 1.0.0 | |
*/ | |
public class WebUtils { | |
public static String cleanXSS(String value) { | |
if (StringUtils.isBlank(value)) { | |
return value; | |
} | |
// You'll need to remove the spaces from the html entities below | |
value = value.trim().replaceAll("<", "<").replaceAll(">", ">"); | |
// 定时组件,当参数的方法名 | |
// value = value.replaceAll("\\(", "(").replaceAll("\\)", ")"); | |
value = value.replaceAll("'", "'"); | |
value = value.replaceAll("eval\\((.*)\\)", ""); | |
value = value.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", | |
"\"\""); | |
return value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment