libdav::encoding

Function strict_percent_encoded

Source
pub fn strict_percent_encoded(input: &str) -> Cow<'_, str>
Expand description

Percent-encode most characters in a path.

The input string may contain percent-encoded characters. All reserved characters which are percent-encoded shall be left untouched. All unreserved characters remain intact. All other non-reserved characters shall be percent-encoded.

reserved    = gen-delims / sub-delims
gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"
sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
             / "*" / "+" / "," / ";" / "="

unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"

The resulting string is not display-friendly, but it suitable for use as path in an HTTP request.

Calling this function with an input where ANY non-reserved character has already been escape will produce a double-encoded output. This output would point to a resource different than the original input.