Giter VIP home page Giter VIP logo

Comments (6)

kmike avatar kmike commented on August 24, 2024

Shouldn't this be handled at HTML parsing time? E.g. if the raw URL was

"http://example.com?foo=bar&bar=foo"

then it'd be http://example.com?foo=bar&bar=foo after unescaping, we shouldn't transform it further to http://example.com?foo=bar&bar=foo.

from w3lib.

redapple avatar redapple commented on August 24, 2024

I second @kmike . I don't think it's w3lib's role to decode HTML entity references.
lxml for example correctly decodes the &:

>>> import lxml.html
>>> t = '''<a href="http://example.com?foo=bar&amp;bar=foo">http://example.com?foo=bar&amp;bar=foo</a><br />'''
>>> doc = lxml.html.fromstring(t)
>>> doc.xpath('//@href')
['http://example.com?foo=bar&bar=foo']

@jvanasco , where did you have an issue with this?

from w3lib.

jvanasco avatar jvanasco commented on August 24, 2024

from w3lib.

Gallaecio avatar Gallaecio commented on August 24, 2024

I agree with @kmike and @redapple here. Even though it is a pain in the ass when this happens, it is not the responsibility of canonicalize_url to handle this.

It should not be fixed, because, albeit weird, http://example.com/?foo=bar&amp;bar=foo is a valid URL different from http://example.com?foo=bar&bar=foo, and so printing a warning may be wrong in itself.

@jvanasco Would you be OK with us closing this issue?

from w3lib.

jvanasco avatar jvanasco commented on August 24, 2024

from w3lib.

Gallaecio avatar Gallaecio commented on August 24, 2024

Thank you!

from w3lib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.