Skip to content

_encode_uri_path_for_uss does not skip encoded URIs #413

Description

@traeok

Describe the bug

_encode_uri_path_for_uss function does not acknowledge encoding on a URI given as input, which can result in invalid URI encoding sequences.

Expected and actual results

Expected: _encode_uri_path_for_uss should either skip encoded URIs, or at least have a note on the function clarifying that it should not be used with a URI that's already encoded.
Actual: The function encodes the URI again, causing incorrect URI encoding.

Example Python logic to detect and return early for this case:

from urllib.parse import unquote

def is_uri_encoded(uri: str) -> bool:
    """Returns True if the URI contains percent-encoded characters."""
    return uri != unquote(uri)

# Examples
print(is_uri_encoded("https://example.com%20world"))  # True
print(is_uri_encoded("https://example.com world"))  # False

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions