xurl

package
v2.38.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package xurl contains small helpers extending the standard net/url package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsEncodedPath

func ContainsEncodedPath(u *url.URL) bool

ContainsEncodedPath reports whether u's path is unsafe to forward to another server with its escaping intact, because that server could resolve it to a different path than the one it was matched on.

net/http.ServeMux matches routes on the escaped path and only cleans literal dot segments, while upstreams decode percent-encoded unreserved characters (RFC 3986 section 6.2.2.2) and then remove dot segments. A path such as /v1/models/%2e%2e/files therefore matches a /v1/models/ route locally but is served as /v1/files upstream.

Each escaped segment is decoded exactly once. It returns true if a segment fails to decode, or if a decoded segment:

  • contains a "." or ".." element, also when split on an escaped "/" or "\" for components that decode reserved characters,
  • still contains "%", which only arises from multiple encoding and would let a component that decodes twice produce a dot segment,
  • contains control characters.

Escaped separators in ordinary segments, such as /models/org%2Fmodel, are allowed.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL