Skip to content

to_iri() changes a literal plus in a query key into a space #213

Backlog

Description

@fernandezbaptiste

Hullo folks,

I'm doing some research for Tessl Code Review and we ran it against your repo. It flagged a potential issue, and I figured it made sense to share it with you:

Reproduction

On 978f2e6, this runs against the unchanged source on Python 3.14.2:

from hyperlink import DecodedURL

u = DecodedURL().set("a+b", "c+d")
print(u.query)
print(u.to_iri().to_text())
print(DecodedURL(u.to_iri()).query)
print(DecodedURL(u.to_uri()).query)

Observed:

(('a+b', 'c+d'),)
?a+b=c%2Bd
(('a b', 'c+d'),)
(('a+b', 'c+d'),)

Expected / impact

The IRI round trip should preserve the query key a+b, as the URI round trip does. Currently a consumer decoding the IRI looks up a different parameter name; the value survives unchanged.

PR #158 protects literal plus signs in query values. The key decode map in _url.py still permits that unquoting, so the same round-trip invariant is missing for keys.

I ran the small example above, including the URI control. I have not prepared a fix or run the full suite.

Full transparency: I work at Tessl, and we've spotted that using Tessl Code Review - using repository-level context and specific review lenses that improve over time through feedback. That’s how this finding surfaced.

We’re just getting started and want to offer the tool free to open-source projects. If this is useful, happy to give you access.

Baptiste

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions