Package org.apache.tomcat.util.buf
Class UDecoder
java.lang.Object
org.apache.tomcat.util.buf.UDecoder
All URL decoding happens here. This way we can reuse, review, optimize without adding complexity to the buffers. The
conversion will modify the original buffer.
- Author:
- Costin Manolache
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
URLDecode, will modify the source.void
convert
(ByteChunk mb, EncodedSolidusHandling encodedSolidusHandling) URLDecode, will modify the source.static String
Decode and return the specified URL-encoded String.
-
Constructor Details
-
UDecoder
public UDecoder()
-
-
Method Details
-
convert
URLDecode, will modify the source. Assumes source bytes are encoded using a superset of US-ASCII as per RFC 7230. "%2f" will be rejected unless the input is a query string.- Parameters:
mb
- The URL encoded bytesquery
-true
if this is a query string. For a query string '+' will be decoded to ' '- Throws:
IOException
- Invalid %xx URL encoding
-
convert
URLDecode, will modify the source. Assumes source bytes are encoded using a superset of US-ASCII as per RFC 7230.- Parameters:
mb
- The URL encoded bytesencodedSolidusHandling
- How should the %2f sequence handled by the decoder? For query strings this parameter will be ignored and the %2f sequence will be decoded- Throws:
IOException
- Invalid %xx URL encoding
-
URLDecode
Decode and return the specified URL-encoded String. It is assumed the string is not a query string.- Parameters:
str
- The url-encoded stringcharset
- The character encoding to use; if null, UTF-8 is used.- Returns:
- the decoded string
- Throws:
IllegalArgumentException
- if a '%' character is not followed by a valid 2-digit hexadecimal number
-