UriRedactor
in package
Table of Contents
Methods
- redactUriForMessage() : string
- Formats a URI for automatic diagnostics.
- redactUriStringForMessage() : string
- Formats a raw URI for automatic diagnostics, including malformed input.
- redactUserInfo() : UriInterface
- Redact the user info part of a URI.
- redactUserInfoInString() : string
- Redacts the userinfo of a raw URI string wherever it appears in a subject string.
Methods
redactUriForMessage()
Formats a URI for automatic diagnostics.
public
static redactUriForMessage(UriInterface $uri) : string
The whole userinfo component is replaced by "***", and the query and fragment are removed. The scheme, host, port, and path are preserved. The returned string is diagnostic-escaped and the formatter never throws.
Parameters
- $uri : UriInterface
Return values
stringredactUriStringForMessage()
Formats a raw URI for automatic diagnostics, including malformed input.
public
static redactUriStringForMessage(string $uri) : string
The whole userinfo component is replaced by "***", and the query and fragment are removed. The scheme, host, port, and path are preserved where their boundaries can be determined safely. The returned string is diagnostic-escaped and the formatter never throws.
Parameters
- $uri : string
Return values
stringredactUserInfo()
Redact the user info part of a URI.
public
static redactUserInfo(UriInterface $uri) : UriInterface
Returns the URI with the whole userinfo component replaced by "***" when one is present, so neither the username nor the password survives into logs and diagnostics. A URI without userinfo is returned unchanged.
Parameters
- $uri : UriInterface
Return values
UriInterfaceredactUserInfoInString()
Redacts the userinfo of a raw URI string wherever it appears in a subject string.
public
static redactUserInfoInString(string $subject, string $uri) : string
The needle is taken verbatim from the raw URI rather than from parsed components, so credentials that URI normalization would rewrite, such as raw control bytes or unencoded reserved characters, are still found in text that embeds the URI exactly as given, for example transport error messages. A URI without "://" is treated as authority-form: a host and port with optional userinfo.
A URI that does not parse has no trustworthy authority boundary, so everything between any scheme and its last "@" is redacted as a safe-side fallback.
Parameters
- $subject : string
-
Text that may embed the URI
- $uri : string
-
Raw URI whose userinfo is redacted in the text