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

urllib2/urllib.parse.splitport does not handle IPv6 correctly #62391

Open
jd mannequin opened this issue Jun 11, 2013 · 9 comments
Open

urllib2/urllib.parse.splitport does not handle IPv6 correctly #62391

jd mannequin opened this issue Jun 11, 2013 · 9 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@jd
Copy link
Mannequin

jd mannequin commented Jun 11, 2013

BPO 18191
Nosy @vstinner, @dhellmann, @jd, @berkerpeksag, @serhiy-storchaka
Dependencies
  • bpo-20270: urllib.parse doesn't work with empty port
  • bpo-20271: urllib.parse.urlparse() accepts wrong URLs
  • Files
  • 0001-Make-urllib.parse.splitport-handle-IPv6-correctly.patch: Patch fixing urllib.parse.splitport
  • test_urlparse.diff: Revised test for urlparse
  • urllib.diff: Revised urllib
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2013-06-11.14:44:39.479>
    labels = ['type-bug', 'library']
    title = 'urllib2/urllib.parse.splitport does not handle IPv6 correctly'
    updated_at = <Date 2014-03-07.16:23:13.722>
    user = 'https://github.com/jd'

    bugs.python.org fields:

    activity = <Date 2014-03-07.16:23:13.722>
    actor = 'vstinner'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2013-06-11.14:44:39.479>
    creator = 'jd'
    dependencies = ['20270', '20271']
    files = ['30558', '31013', '31015']
    hgrepos = []
    issue_num = 18191
    keywords = ['patch']
    message_count = 9.0
    messages = ['190968', '191027', '191040', '191041', '191042', '193546', '193548', '208157', '212891']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'samwyse', 'doughellmann', 'jd', 'berker.peksag', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue18191'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

    @jd
    Copy link
    Mannequin Author

    jd mannequin commented Jun 11, 2013

    >>> import urllib.parse
    >>> urllib.parse.splitport("::1")
    (':', '1')

    This is obviously invalid.

    @jd jd mannequin added the stdlib Python modules in the Lib dir label Jun 11, 2013
    @jd
    Copy link
    Mannequin Author

    jd mannequin commented Jun 12, 2013

    Attached is a patch inspired by a function written for OpenStack Oslo library.

    @dhellmann
    Copy link
    Member

    LGTM

    @serhiy-storchaka
    Copy link
    Member

    I see only tests.

    It is more common to use arguments for assertEqual() in the reverse order, first actual value, and than expected value.

    @berkerpeksag
    Copy link
    Member

    FTR, urllib.parse.splitport is undocumented and it is only used by urllib.request in the stdlib.

    @samwyse
    Copy link
    Mannequin

    samwyse mannequin commented Jul 22, 2013

    Fixes Serhiy Storchaka's complaints, removes duplicate test.

    @samwyse
    Copy link
    Mannequin

    samwyse mannequin commented Jul 22, 2013

    Handles "raw" IPv6 URLs

    @serhiy-storchaka
    Copy link
    Member

    Julien's patch is subject to bugs described in bpo-20270 and bpo-20271. As far as OpenStack Oslo library.

    @serhiy-storchaka serhiy-storchaka added the type-bug An unexpected behavior, bug, or error label Jan 15, 2014
    @vstinner
    Copy link
    Member

    vstinner commented Mar 7, 2014

    I posted a patch to bpo-20271 which should fix the issue. I wrote the patch for Python 3.5, but it can be adapted to be tolerant (don't make extensive tests on port number, host and IPv6) for older versions.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants