addressable icon indicating copy to clipboard operation
addressable copied to clipboard

`normalized_encode` incorrectly unencodes `%26` to `&`

Open davidtaylorhq opened this issue 4 years ago • 1 comments

When a query parameter includes %26, normalized_encode replaces it with a literal &, which results in a different URI:

pry(main)> Addressable::URI.normalized_encode("https://example.com?foo=bar%26baz")
=> "https://example.com?foo=bar&baz"

The more comprehensive URI#normalize method works correctly:

pry(main)> Addressable::URI.parse("https://example.com?foo=bar%26baz").normalize.to_s
=> "https://example.com/?foo=bar%26baz"

This issue is possibly related to #366 and #386. However, both of those issues apply to URI#normalize, wheras this %26 issue only seems to apply to the normalized_encode method.

davidtaylorhq avatar Jul 28 '21 16:07 davidtaylorhq

I think this issue is the same as https://github.com/sporkmonger/addressable/issues/366 but I'll keep this one open until it has been addressed.

dentarg avatar Jul 19 '23 06:07 dentarg