Package com.aoindustries.servlet.filter
Class StripInvalidXmlCharactersFilter
- java.lang.Object
-
- com.aoindustries.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
andDispatcherType.ERROR
dispatchers.
-
-
Constructor Summary
Constructors Constructor Description StripInvalidXmlCharactersFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
void
doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
void
init(FilterConfig config)
-
-
-
Method Detail
-
init
public void init(FilterConfig config)
-
doFilter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
- Specified by:
doFilter
in interfaceFilter
- Throws:
IOException
ServletException
-
-