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
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionDeprecated.Unused.voidURLDecode, will modify the source.voidconvert(ByteChunk mb, EncodedSolidusHandling encodedSolidusHandling) Deprecated.Unused.voidconvert(ByteChunk mb, EncodedSolidusHandling encodedSolidusHandling, EncodedSolidusHandling encodedReverseSolidusHandling) URLDecode, will modify the source.voidDeprecated.Unused.voidconvert(MessageBytes mb, boolean query) Deprecated.Unused.static StringDeprecated.Unused.static StringDecode and return the specified URL-encoded String.static StringURLDecode(String str, Charset charset, EncodedSolidusHandling encodedSolidusHandling, EncodedSolidusHandling encodedReverseSolidusHandling) Decode and return the specified URL-encoded String.
- 
Field Details- 
ALLOW_ENCODED_SLASHDeprecated.
 
- 
- 
Constructor Details- 
UDecoderpublic UDecoder()
 
- 
- 
Method Details- 
convertURLDecode, will modify the source. Assumes source bytes are encoded using a superset of US-ASCII as per RFC 7230. "%5c" will be decoded. "%2f" will be rejected unless the input is a query string.- Parameters:
- mb- The URL encoded bytes
- query-- trueif this is a query string. For a query string '+' will be decoded to ' '
- Throws:
- IOException- Invalid %xx URL encoding
 
- 
convert@Deprecated public void convert(ByteChunk mb, EncodedSolidusHandling encodedSolidusHandling) throws IOException Deprecated.Unused. Will be removed in Tomcat 12. Useconvert(ByteChunk, EncodedSolidusHandling, EncodedSolidusHandling)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 bytes
- encodedSolidusHandling- 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
 
- 
convertpublic void convert(ByteChunk mb, EncodedSolidusHandling encodedSolidusHandling, EncodedSolidusHandling encodedReverseSolidusHandling) throws IOException 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 bytes
- encodedSolidusHandling- How should the %2f sequence handled by the decoder? For query strings this parameter will be ignored and the %2f sequence will be decoded
- encodedReverseSolidusHandling- How should the %5c sequence handled by the decoder? For query strings this parameter will be ignored and the %5c sequence will be decoded
- Throws:
- IOException- Invalid %xx URL encoding
 
- 
convertDeprecated.Unused. Will be removed in Tomcat 10In-buffer processing - the buffer will be modified.WARNING: This method assumes US-ASCII encoding. - Parameters:
- mb- The URL encoded chars
- query-- trueif this is a query string
- Throws:
- IOException- Invalid %xx URL encoding
 
- 
convertDeprecated.Unused. Will be removed in Tomcat 10URLDecode, will modify the source.WARNING: This method assumes US-ASCII encoding. - Parameters:
- mb- The URL encoded String, bytes or chars
- query-- trueif this is a query string
- Throws:
- IOException- Invalid %xx URL encoding
 
- 
convertDeprecated.Unused. Will be removed in Tomcat 10%xx decoding of a string.WARNING: This method assumes US-ASCII encoding. FIXME: this is inefficient. - Parameters:
- str- The URL encoded string
- query-- trueif this is a query string
- Returns:
- the decoded string
 
- 
URLDecodeDeprecated.Unused. This will be removed in Tomcat 10 onwardsDecode and return the specified URL-encoded String. When the byte array is converted to a string, UTF-8 is used. This may be different than some other servers. It is assumed the string is not a query string.- Parameters:
- str- The url-encoded string
- Returns:
- the decoded string
- Throws:
- IllegalArgumentException- if a '%' character is not followed by a valid 2-digit hexadecimal number
 
- 
URLDecodeDecode and return the specified URL-encoded String. It is assumed the string is not a query string.- Parameters:
- str- The url-encoded string
- charset- 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
 
- 
URLDecodepublic static String URLDecode(String str, Charset charset, EncodedSolidusHandling encodedSolidusHandling, EncodedSolidusHandling encodedReverseSolidusHandling) Decode and return the specified URL-encoded String. It is assumed the string is not a query string.- Parameters:
- str- The url-encoded string
- charset- The character encoding to use; if null, UTF-8 is used.
- encodedSolidusHandling- The required handling of encoded solidus (%2f - /)
- encodedReverseSolidusHandling- The required handling of encoded reverse solidus (%5c - \)
- Returns:
- the decoded string
- Throws:
- IllegalArgumentException- if a '%' character is not followed by a valid 2-digit hexadecimal number
 
 
-