Package com.aoindustries.servlet.filter
Class EncodeURIFilter
- java.lang.Object
-
- com.aoindustries.servlet.filter.EncodeURIFilter
-
- All Implemented Interfaces:
Filter
public class EncodeURIFilter extends Object implements Filter
Encodes the URL to either RFC 3986 URI US-ASCII format or RFC 3987 IRI Unicode format. If the URL begins with
javascript:
,cid:
, ordata:
, (case-insensitive) it is not altered. Canonical URLs are always encoded to US-ASCII format.IRI support is disabled by default, and only recommended for development or internal systems. IRI may result in slightly smaller output, and more readable HTML source, but for interoperability should be off in production systems.
RFC 7231 - 7.1.2. Location refers only to RFC 3986 URI for URI-reference, thus redirects are always formatted as RFC 3986 URI.
This should be used for both the
DispatcherType.REQUEST
andDispatcherType.ERROR
dispatchers.
-
-
Constructor Summary
Constructors Constructor Description EncodeURIFilter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
destroy()
void
doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
String
encode(String url, Doctype doctype, String characterEncoding)
Performs encoding on the given URL in the given response encoding.String
encode(String url, String characterEncoding)
Deprecated.Please provide the currentDoctype
so can be enabled selectively viaDoctype.supportsIRI()
.static EncodeURIFilter
getActiveFilter(ServletRequest request)
Gets the filter active on the given request.void
init(FilterConfig config)
-
-
-
Method Detail
-
getActiveFilter
public static EncodeURIFilter getActiveFilter(ServletRequest request)
Gets the filter active on the given request.- Returns:
- The currently active filter or
null
for none active.
-
init
public void init(FilterConfig config)
-
encode
public String encode(String url, Doctype doctype, String characterEncoding)
Performs encoding on the given URL in the given response encoding.
-
encode
@Deprecated public String encode(String url, String characterEncoding)
Deprecated.Please provide the currentDoctype
so can be enabled selectively viaDoctype.supportsIRI()
.Performs encoding on the given URL in the given response encoding.
-
doFilter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
- Specified by:
doFilter
in interfaceFilter
- Throws:
IOException
ServletException
-
-