Package org.apache.tomcat.util.buf
Class UDecoder
- java.lang.Object
-
- org.apache.tomcat.util.buf.UDecoder
-
public final class UDecoder extends java.lang.ObjectAll URL decoding happens here. This way we can reuse, review, optimize without adding complexity to the buffers. The conversion will modify the original buffer.
-
-
Constructor Summary
Constructors Constructor Description UDecoder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidconvert(ByteChunk mb, boolean query)URLDecode, will modify the source.voidconvert(ByteChunk mb, EncodedSolidusHandling encodedSolidusHandling)Deprecated.Unused.voidconvert(ByteChunk mb, EncodedSolidusHandling encodedSolidusHandling, EncodedSolidusHandling encodedReverseSolidusHandling)URLDecode, will modify the source.static java.lang.StringURLDecode(java.lang.String str, java.nio.charset.Charset charset)Decode and return the specified URL-encoded String.static java.lang.StringURLDecode(java.lang.String str, java.nio.charset.Charset charset, EncodedSolidusHandling encodedSolidusHandling, EncodedSolidusHandling encodedReverseSolidusHandling)Decode and return the specified URL-encoded String.
-
-
-
Method Detail
-
convert
public void convert(ByteChunk mb, boolean query) throws java.io.IOException
URLDecode, 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 bytesquery-trueif this is a query string. For a query string '+' will be decoded to ' '- Throws:
java.io.IOException- Invalid %xx URL encoding
-
convert
@Deprecated public void convert(ByteChunk mb, EncodedSolidusHandling encodedSolidusHandling) throws java.io.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 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:
java.io.IOException- Invalid %xx URL encoding
-
convert
public void convert(ByteChunk mb, EncodedSolidusHandling encodedSolidusHandling, EncodedSolidusHandling encodedReverseSolidusHandling) throws java.io.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 bytesencodedSolidusHandling- How should the %2f sequence handled by the decoder?encodedReverseSolidusHandling- How should the %5c sequence handled by the decoder?- Throws:
java.io.IOException- Invalid %xx URL encoding
-
URLDecode
public static java.lang.String URLDecode(java.lang.String str, java.nio.charset.Charset charset)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:
java.lang.IllegalArgumentException- if a '%' character is not followed by a valid 2-digit hexadecimal number
-
URLDecode
public static java.lang.String URLDecode(java.lang.String str, java.nio.charset.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 stringcharset- 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:
java.lang.IllegalArgumentException- if a '%' character is not followed by a valid 2-digit hexadecimal number
-
-