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
Describe the bug
_encode_uri_path_for_ussfunction 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_ussshould 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: