Skip to main content

Module uri

Module uri 

Source
Expand description

URI component encoder.

provides percent-encoding for URI components per RFC 3986.

§security notes

  • this encoder is for URI components (query parameters, path segments, fragment identifiers), not entire URLs.
  • it cannot make an untrusted full URL safe. a javascript: URL will be percent-encoded but still execute. always validate the URL scheme and structure separately before embedding untrusted URLs.
  • the output is safe for direct embedding in HTML, CSS, and javascript contexts because all context-significant characters are percent-encoded.

Functions§

for_uri_component
percent-encodes input for safe use as a URI component.
write_uri_component
writes the percent-encoded form of input to out.