Skip to content

Can't handle URLs with @ character in userinfo section #328

Closed

Description

@sethmlarson
>>> import httpx
>>> httpx.URL("https://user@gmail.com:password@google.com")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sethmlarson/Desktop/http3/httpx/models.py", line 112, in __init__
    raise InvalidURL("No host included in URL.")
httpx.exceptions.InvalidURL: No host included in URL.

This is a common use-case for proxies and websites using email addresses as usernames for authentication.

This might require a change in rfc3986 or the way we parse URLs. :)

Activity

  1. cansarigol commented on Sep 9, 2019

    @cansarigol
    Contributor

    Hi @sethmlarson I've pushed a PR about this topic. Could your review it?

  2. lovelydinosaur commented on Jul 27, 2020

    @lovelydinosaur
    Member

    So, something I think we may want to re-review prior to 1.0 is which internal URL parsing implementation is really our best option. This issue (and perhaps also #858, although maybe that's exclusively an issue on our side?) currently means that we're a little less robust on URL parsing than the wonderfully battle hardened urllib3, which is something we ought to resolve.

    Making a change here wouldn't have any affect on our public API. That's tied down and looks that way we want. But this could potentially change which dependancies we choose to ship with.

    Some options here are...

    • Stick with rfc3986. Because we're doing just fine really. Let's just make sure we're contributing our time to helping getting this issue resolved.
    • Consider irl.
    • Switch to the urllib3 implementation, possibly by vendoring just the URL parsing into a (properly licensed and credited) slimline stand-alone package that just implements plain functions for url_parse and url_join, that only deal with super plain named-tuple-like arguments.

    Of those three options, the last seems like it'd be the most robust approach, since urllib3 have been doing this for years. Having said that, I don't really have enough context about which of these three options the urllib3 team themselves would consider to be most suitable.

    No doubt @sigmavirus24 and @sethmlarson both have far more insight into this, tho I don't want to push for anyone's time here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions