Skip to main content

Module uri

Module uri 

Source
Expand description

URI and form percent-encoders.

provides percent-encoding for URI components and paths per RFC 3986, and for form values per the WHATWG URL Standard (application/x-www-form-urlencoded).

§security notes

  • these encoders are for URI components, paths, and form values, not entire URLs.
  • they 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_form_urlencoded
percent-encodes input for use as an application/x-www-form-urlencoded value.
for_uri_component
percent-encodes input for safe use as a URI component.
for_uri_path
percent-encodes input for safe use as a URI path.
write_form_urlencoded
writes the application/x-www-form-urlencoded encoded form of input to out.
write_uri_component
writes the percent-encoded form of input to out.
write_uri_path
writes the percent-encoded URI path form of input to out.