Skip to content

Keep the urlhash stable when Addressable changes how it reads + in query names - #174

Open
dentarg wants to merge 2 commits into
twingly:masterfrom
dentarg:pin-plus-in-query-names
Open

dentarg wants to merge 2 commits into
twingly:masterfrom
dentarg:pin-plus-in-query-names

Conversation

@dentarg

@dentarg dentarg commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Extended#normalized built the normalized query from Addressable::URI#query_values, so the urlhash depended on how Addressable reads a query. The next Addressable release (2.10.0, sporkmonger/addressable#607) reads + in a parameter name as a space, as form encoding does. Every URL with a + in a parameter name would then get a new normalized_url and urlhash: https://example.com/?a+b=c would go from ?a%2Bb=c to ?a%20b=c.

Changes

  • Specs pinning the current behaviour: + in a parameter name stays a plus (%2B in normalized_url), + in a value is a space, and %2B is a plus in both. This includes the urlhash and legacy urlhash for https://example.com/?a+b=c. These specs fail against Addressable main without the second commit.
  • Extended#query_values parses the query itself, the way Addressable up to 2.9.2 does, so the urlhash no longer depends on the Addressable version. The blacklist check uses the same name decoding.

Not covered

callable_url is still Addressable's normalized URL, so it changes with 2.10.0 in a few cases. Addressable no longer decodes a pct-encoded delimiter in a way that changes the URL's meaning: ?a=%252B stays ?a=%252B instead of becoming ?a=%2B, and ?a%3Db=1 stays as it is instead of becoming ?a=b=1. The urlhash isn't affected.

Addressable::URI#query_values keeps a literal '+' in a parameter name as
a plus, so Extended#normalized writes it as '%2B'. The next Addressable
release reads it as a space, which changes normalized_url and with it
the urlhash. These specs fail when that happens.
Extended#normalized built the normalized query from
Addressable::URI#query_values, so the urlhash followed however
Addressable reads a query. The next Addressable release reads '+' in a
parameter name as a space, which would change the urlhash of every URL
with such a name.

Extended#query_values now splits and decodes the query itself, the way
Addressable up to 2.9.2 does: '+' is a plus in a name and a space in a
value. The output is the same for every Addressable version.
@dentarg dentarg mentioned this pull request Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant