Class StripInvalidXmlCharactersFilter

java.lang.Object
com.aoapps.servlet.filter.StripInvalidXmlCharactersFilter
All Implemented Interfaces:
Filter

public class StripInvalidXmlCharactersFilter extends Object implements Filter

Strips all invalid XML characters on incoming parameters. GET requests on the DispatcherType.REQUEST dispatcher will be 301-redirected to the same URL without the invalid XML characters. All other methods and all other dispatchers, including POST requests, will have the invalid XML characters stripped.

Parameters with invalid names are removed.

This implementation supports UTF-16 surrogate pairs: https://wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates

The allowed characters defined by the specification at https://www.w3.org/TR/xml/#charsets:

Char   ::=   #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]

Only HTTP/HTTPS requests are filtered.

This should be used for both the DispatcherType.REQUEST and DispatcherType.ERROR dispatchers.