Top Constructors Methods
org.apache.tomcat.util.http

public Class RequestUtil

extends Object
Class Inheritance
Imports
java.net.URI, .URISyntaxException, java.util.Locale, jakarta.servlet.http.HttpServletRequest

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean
public static boolean

Returns:

true if the origin was valid
isValidOrigin
(String
The origin URI
origin
)

Checks if a given origin is valid or not.

public static String

Returns:

The normalized path or null if the path cannot be normalized
normalize
(String
Relative path to be normalized
path
)

Normalize a relative URI path that may have relative values ("/./", "/../", and so on ) it it

Warning

- This method is useful only for normalizing application-generated paths.

public static String

Returns:

The normalized path or null if the path cannot be normalized
normalize
(String
Relative path to be normalized
path
,
boolean
Should '\\' be replaced with '/'
replaceBackSlash
)

Normalize a relative URI path that may have relative values ("/./", "/../", and so on ) it it

Warning

- This method is useful only for normalizing application-generated paths.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RequestUtilback to summary
private RequestUtil()

Method Detail

isSameOriginback to summary
public static boolean isSameOrigin(HttpServletRequest request, String origin)
isValidOriginback to summary
public static boolean isValidOrigin(String origin)

Checks if a given origin is valid or not. Criteria:

  • If an encoded character is present in origin, it's not valid.
  • If origin is "null", it's valid.
  • Origin should be a valid URI
Parameters
origin:String

The origin URI

Returns:boolean

true if the origin was valid

See Also
RFC952
normalizeback to summary
public static String normalize(String path)

Normalize a relative URI path that may have relative values ("/./", "/../", and so on ) it it

Warning

- This method is useful only for normalizing application-generated paths. It does not try to perform security checks for malicious input.

Parameters
path:String

Relative path to be normalized

Returns:String

The normalized path or null if the path cannot be normalized

normalizeback to summary
public static String normalize(String path, boolean replaceBackSlash)

Normalize a relative URI path that may have relative values ("/./", "/../", and so on ) it it

Warning

- This method is useful only for normalizing application-generated paths. It does not try to perform security checks for malicious input.

Parameters
path:String

Relative path to be normalized

replaceBackSlash:boolean

Should '\\' be replaced with '/'

Returns:String

The normalized path or null if the path cannot be normalized