I am writing a servlet filter to safeguard the site from XSS Vulnerabilities. I need a whitelist that I can apply against HTTPRequest so that I can avoid any malicious script and characters.
Can I use regular expressions as a whitelist? Which regular expression should I use so that it will include all the characters of the URL. Any other solution is also welcome.
Please suggest me how to create whitelist for the URL of the application.
Thanks in advance.
Update - Please do not mark its down vote. See my research in comments. I already researched a lot about this.