public class HttpRequestURIDecoder extends Object
MessageBytes
is normalized, converted and valid. It also makes sure there is no security
hole. Mainly, this class can be used by doing:
HttpRequestURIDecoder.decode(decodedURI, urlDecoder, encoding, b2cConverter);
Modifier and Type | Field and Description |
---|---|
protected static boolean |
ALLOW_BACKSLASH |
Constructor and Description |
---|
HttpRequestURIDecoder() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkNormalize(CharChunk uriCC)
Check that the URI is normalized following character decoding.
|
protected void |
convertMB(MessageBytes mb)
Character conversion of the a US-ASCII MessageBytes.
|
static void |
convertToChars(DataChunk decodedURI,
Charset encoding)
Converts the normalized the HTTP request represented by the bytes inside
DataChunk to chars representation, using the passed encoding. |
protected static void |
copyBytes(byte[] b,
int dest,
int src,
int len)
Copy an array of bytes to a different position.
|
static void |
decode(DataChunk decodedURI)
Decode the HTTP request represented by the bytes inside
DataChunk . |
static void |
decode(DataChunk decodedURI,
boolean isSlashAllowed)
Decode the HTTP request represented by the bytes inside
DataChunk . |
static void |
decode(DataChunk decodedURI,
boolean isSlashAllowed,
Charset encoding)
Decode the HTTP request represented by the bytes inside
DataChunk . |
static void |
decode(DataChunk originalURI,
DataChunk targetDecodedURI,
boolean isSlashAllowed,
Charset encoding)
Decode the HTTP request represented by the bytes inside
DataChunk . |
static void |
decode(MessageBytes decodedURI,
UDecoder urlDecoder)
Decode the http request represented by the bytes inside
MessageBytes
using an UDecoder . |
static void |
decode(MessageBytes decodedURI,
UDecoder urlDecoder,
String encoding,
B2CConverter b2cConverter)
Decode the HTTP request represented by the bytes inside
MessageBytes
using an UDecoder , using the specified encoding, using the specified
[@link B2CConverter} to decode the request. |
protected void |
log(String message)
Log a message on the Logger associated with our Container (if any)
|
protected void |
log(String message,
Throwable throwable)
Log a message on the Logger associated with our Container (if any)
|
static boolean |
normalize(DataChunk dataChunk)
Normalize URI.
|
static boolean |
normalize(MessageBytes uriMB)
Normalize URI.
|
static boolean |
normalizeBuffer(BufferChunk bc) |
static boolean |
normalizeBytes(ByteChunk bc) |
static boolean |
normalizeChars(CharChunk uriCC) |
protected static final boolean ALLOW_BACKSLASH
public static void decode(MessageBytes decodedURI, UDecoder urlDecoder) throws Exception
MessageBytes
using an UDecoder
.decodedURI
- - The bytes to decodeurlDecoder
- - The urlDecoder to use to decode.Exception
public static void decode(MessageBytes decodedURI, UDecoder urlDecoder, String encoding, B2CConverter b2cConverter) throws Exception
MessageBytes
using an UDecoder
, using the specified encoding, using the specified
[@link B2CConverter} to decode the request.decodedURI
- - The bytes to decodeurlDecoder
- - The urlDecoder to use to decode.encoding
- the encoding value, default is UTF-8.b2cConverter
- the Bytes to Char Converter.Exception
public static void decode(DataChunk decodedURI) throws CharConversionException
DataChunk
.decodedURI
- - The bytes to decodeException
CharConversionException
public static void decode(DataChunk decodedURI, boolean isSlashAllowed) throws CharConversionException
DataChunk
.decodedURI
- - The bytes to decodeisSlashAllowed
- allow encoded slashesException
CharConversionException
public static void decode(DataChunk decodedURI, boolean isSlashAllowed, Charset encoding) throws CharConversionException
DataChunk
.decodedURI
- - The bytes to decodeencoding
- the encoding value, default is UTF-8.Exception
CharConversionException
public static void decode(DataChunk originalURI, DataChunk targetDecodedURI, boolean isSlashAllowed, Charset encoding) throws CharConversionException
DataChunk
.originalURI
- - The bytes to decodetargetDecodedURI
- the target DataChunk
URI will be decoded toisSlashAllowed
- is '/' an allowable characterencoding
- the encoding value, default is UTF-8Exception
CharConversionException
public static void convertToChars(DataChunk decodedURI, Charset encoding) throws CharConversionException
DataChunk
to chars representation, using the passed encoding.decodedURI
- - The bytes to decodeencoding
- the encoding value, default is UTF-8.Exception
CharConversionException
public static boolean normalize(MessageBytes uriMB)
This method normalizes "\", "//", "/./" and "/../". This method will return false when trying to go above the root, or if the URI contains a null byte.
uriMB
- URI to be normalizedpublic static boolean normalize(DataChunk dataChunk)
This method normalizes "\", "//", "/./" and "/../". This method will return false when trying to go above the root, or if the URI contains a null byte.
dataChunk
- URI to be normalizedpublic static boolean checkNormalize(CharChunk uriCC)
This method checks for "\", 0, "//", "/./" and "/../". This method will return false if sequences that are supposed to be normalized are still present in the URI.
uriCC
- URI to be checked (should be chars)public static boolean normalizeChars(CharChunk uriCC)
protected static void copyBytes(byte[] b, int dest, int src, int len)
protected void log(String message)
message
- Message to be loggedprotected void log(String message, Throwable throwable)
message
- Message to be loggedthrowable
- Associated exceptionprotected void convertMB(MessageBytes mb)
public static boolean normalizeBytes(ByteChunk bc)
public static boolean normalizeBuffer(BufferChunk bc)
Copyright © 2014 Oracle Corporation. All rights reserved.