java.lang.Object
org.htmlunit.csp.Utils
Internal utility methods and constants used by the CSP parser.
Provides string-manipulation helpers that follow the algorithms defined in the Infra Standard, including split on ASCII whitespace and strictly split, as well as Base64 validation, URL-decoding, and token extraction.
- Author:
- Salvation Team
-
Field Summary
FieldsModifier and TypeFieldDescriptionPredicate that tests whether a string matches the Base64 value grammar used in CSP nonce-sources and hash-sources. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractLeadingToken(String input) Extracts the first contiguous sequence of non-ASCII-whitespace characters from the beginning of the input string.static StringTrims leading and trailing ASCII whitespace (\t,\n,\f,\r, and space) from the given string.
-
Field Details
-
IS_BASE64_VALUE
Predicate that tests whether a string matches the Base64 value grammar used in CSP nonce-sources and hash-sources.Accepts characters
a-zA-Z0-9+/-_followed by zero, one, or two padding=characters.
-
-
Method Details
-
trimAsciiWhitespace
Trims leading and trailing ASCII whitespace (\t,\n,\f,\r, and space) from the given string.- Parameters:
str- the string to trim (can benull)- Returns:
- the trimmed string, or
nullif the input isnull, or an empty string if the input consists entirely of whitespace
-
extractLeadingToken
Extracts the first contiguous sequence of non-ASCII-whitespace characters from the beginning of the input string.If the string starts with whitespace, is
null, or is empty, an empty string is returned.- Parameters:
input- the input string (can benull)- Returns:
- the leading token, or an empty string if no leading token is present
-