Skip to content

Incorrect behaviour for user@password URI pattern in urlparse #81859

Closed as not planned

Description

@truebit
mannequin
BPO 37678
Nosy @truebit, @potomak

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 2019-07-25.09:49:26.624>
labels = ['3.7', 'type-bug', 'library']
title = 'Incorrect behaviour for user@password URI pattern in urlparse'
updated_at = <Date 2019-07-29.03:30:11.402>
user = 'https://github.com/truebit'

bugs.python.org fields:

activity = <Date 2019-07-29.03:30:11.402>
actor = 'potomak'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2019-07-25.09:49:26.624>
creator = 'Sean.Wang'
dependencies = []
files = []
hgrepos = []
issue_num = 37678
keywords = []
message_count = 2.0
messages = ['348431', '348593']
nosy_count = 2.0
nosy_names = ['Sean.Wang', 'potomak']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue37678'
versions = ['Python 2.7', 'Python 3.5', 'Python 3.6', 'Python 3.7']

Activity

  1. truebit commented on Jul 25, 2019

    truebitmannequin
    MannequinAuthor

    When an IPV4 URL with 'username:password' in it, and the password contains special characters like #[]?, urlparse would act as unexcepted.
    example:

    urlparse('http://user:pass#?[word@example.com:80/path')
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    type-bugAn unexpected behavior, bug, or error
    on Jul 25, 2019
  3. potomak commented on Jul 29, 2019

    potomakmannequin
    Mannequin

    What do you mean that urlparse act as unexpected?

    I tried your example and I think urlparse's behavior is correct.

    From the RFC 1738:

    Octets must be encoded if they have no corresponding graphic
    character within the US-ASCII coded character set, if the use of the
    corresponding character is unsafe, or if the corresponding character
    is reserved for some other interpretation within the particular URL
    scheme.

    Your example:

    >>> from urllib.parse import urlparse
    >>> urlparse('http://user:pass#?[word@example.com:80/path')
    ParseResult(scheme='http', netloc='user:pass', path='', params='', query='', fragment='?[word@example.com:80/path')
    

    Part of the password is parsed as the URL fragment because the character # has a special meaning:

    The character "#" is unsafe and should
    always be encoded because it is used in World Wide Web and in other
    systems to delimit a URL from a fragment/anchor identifier that might
    follow it.

  4. transferred this issue fromon Apr 10, 2022
  5. saito828koki commented on Oct 5, 2022

    @saito828koki
    Contributor

    This is not a bug. This issue can be closed.

  6. davidism commented on Jan 31, 2024

    @davidism

    @serhiy-storchaka this is the same invalid issue as #110869 which you just closed. This can be closed as well.

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

    3.7 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions