sporkmonger / addressable

Addressable is an alternative implementation to the URI implementation that is part of Ruby's standard library. It is flexible, offers heuristic parsing, and additionally provides extensive support for IRIs and URI templates.
Apache License 2.0
1.56k stars 266 forks source link

Ignore %2B in normalize #386

Open douglara opened 4 years ago

douglara commented 4 years ago

When passing a string that contains '%2B' the normalize method remove '%2B'

Example:

url = 'https://melianuncios-generic-s3-development.s3.us-east-2.amazonaws.com/dmfacessorios/MONITOR+FIXO%2BSENSOR+PRATA.jpg' Addressable::URI.parse(url).normalize.to_s Return: "https://melianuncios-generic-s3-development.s3.us-east-2.amazonaws.com/dmfacessorios/MONITOR+FIXO+SENSOR+PRATA.jpg"

I found this PR related: https://github.com/sporkmonger/addressable/pull/99

Addressable version: 2.7.0

dentarg commented 4 years ago

What do you expect to happen? What version of Addressable are you using?

douglara commented 4 years ago

What do you expect to happen? What version of Addressable are you using?

Sorry forgot to add the version but it is the most recent: 2.7.0

I passed him an already normalized url, my expectation would be that he would do nothing but he is removing characteres '%2B' and invalidating my url.

Please correct me if I'm wrong, thanks!

dentarg commented 4 years ago

What does the URL look like before the first normalize? Did you normalize it with Addressable?

Please share a complete code example (see https://guides.github.com/features/mastering-markdown/#examples for how to format code)

douglara commented 4 years ago

What does the URL look like before the first normalize?

Im not normalized, the AWS S3 already delivers the "normalized" link image Valid link: https://melianuncios-generic-s3-development.s3.us-east-2.amazonaws.com/dmfacessorios/MONITOR+FIXO%2BSENSOR+PRATA.jpg

Did you normalize it with Addressable?

Im not changed the original link.

Please share a complete code example (see https://guides.github.com/features/mastering-markdown/#examples for how to format code)

valid_url = 'https://melianuncios-generic-s3-development.s3.us-east-2.amazonaws.com/dmfacessorios/MONITOR+FIXO%2BSENSOR+PRATA.jpg'
invalid_url = Addressable::URI.parse(valid_url).normalize.to_s
invalid_url => "https://melianuncios-generic-s3-development.s3.us-east-2.amazonaws.com/dmfacessorios/MONITOR+FIXO+SENSOR+PRATA.jpg" 

image

dentarg commented 4 years ago

Feels very similar to #366 (in #366 the issue is in the query parameters, not sure how that matters)

dentarg commented 1 year ago

Related: #99 (https://github.com/sporkmonger/addressable/commit/72bf6c014d5844c87a83a955807d56f2f445d1f0) made %2B in query strings to be preserved during normalisation

dentarg commented 1 year ago

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.