Need to escape Special Characters in Java Web Application
listed in answer
ANSWER:
you can pattern match the string and either build a black list of invalid characters or have a white list of valid characters….something like the following
Pattern p = Pattern.compile(blackList); // or reverse with a white list
Matcher m = p.matcher(unsafeInputString);
if (m.matches())
// Invalid input: reject it, or remove/change the offending characters.
else
// Valid input.
by nate_weldon from http://stackoverflow.com/questions/10317029

New Comments