Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL sanitization fails on URLs containing percent-encoding #74

Open
spencerwilson opened this issue Apr 25, 2024 · 0 comments
Open

URL sanitization fails on URLs containing percent-encoding #74

spencerwilson opened this issue Apr 25, 2024 · 0 comments

Comments

@spencerwilson
Copy link

spencerwilson commented Apr 25, 2024

Describe the bug

URL sanitization is overly aggressive on URLs containing percent-encoded data

Steps to reproduce the issue

Run the following on v1.1:

>>> gazpacho.utils.sanitize('https://en.wikipedia.org/wiki/M%26M%27s')
'https://en.wikipedia.org/wiki/M%2526M%2527s'

Alternatively, on 7cc9488 with a tweak to get the package loadable, and logging str(url):

>>> gazpacho.get('https://en.wikipedia.org/wiki/M%26M%27s')
url http://https://en.wikipedia.org/wiki/M%2526M%2527s
...

(i.e., no change)

This results in certain URLs not being get-able. In my case en.wikipedia.org serves a 404 response.

To get 7cc9488 importable I changed

from .soup import Soup
to

from .soup2 import Soup

Expected behavior

The valid URL I give is unchanged during sanitization, and is fetched successfully.

Environment:

  • OS: macOS
  • Version: 14.2.1

Python 3.11.3

Additional information

Seems like occurrences of % are getting rewritten as %25.

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

No branches or pull requests

1 participant