This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: urlparse: add userinfo attribute
Type: enhancement Stage:
Components: None Versions: Python 3.4
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: olof, orsenthil
Priority: normal Keywords: patch

Created on 2013-01-09 14:46 by olof, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
urlparse_userinfo.diff olof, 2013-01-09 14:46 Patch adding a userinfo attribute review
Messages (3)
msg179447 - (view) Author: Olof Johansson (olof) Date: 2013-01-09 14:46
Hi,

The urlparse library's "netloc" attribute is today further split into the following attributes: username, password, hostname, port. The attributes preceding the @ (username, password) are refered to in RFC 3986 [1] as "userinfo", the format of which is scheme dependant. E.g. the (expired) internet draft for SSH/SFTP urls [2] have connection parameters within the userinfo (user;cparams@host).

In some cases, the deprecated "username:password" syntax is required to be supported even with, e.g. "connection parameters". For this reason, I propose a new attribute, "userinfo", that exposes the "raw" userinfo string, without any splitting on : etc. I've had a go at a patch, with updated unit tests and documentation. Any feedback is welcome!

Regards,

1: http://tools.ietf.org/rfc/rfc3986.txt
2: http://tools.ietf.org/id/draft-ietf-secsh-scp-sftp-ssh-uri-04.txt
msg179476 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-01-09 17:07
If it does go in, due the RFC requirement, then it would be only in 3.4 (default branch) and the feature may not be backported. Without reading the RFC section, I have an intuitive -1 for this proposal because the suggestion may be a corner case rather than a default scenario. It is a bad idea to change parsing logic for corner cases.
msg179533 - (view) Author: Olof Johansson (olof) Date: 2013-01-10 08:24
Thank you for you feedback. I agree, the reason I wanted this was because of a corner case, but otoh, the username:password syntax is the real corner case imho. Of course, I understand that this must be supported for backwards compatability.

(For fully RFC compliant URLs however, userinfo would be the same as user since : in userinfo isn't allowed, so again, you have a very valid point for your corner case argument.)

The patch was developed against 2.7, so it won't apply on 3.4, but looking at 3.4, urlparse already has a _userinfo property method, but it splits the userinfo in a tuple of (username, password). It would be easy to adapt the change to 3.4, but I'll wait until I get additional feedback.
History
Date User Action Args
2022-04-11 14:57:40adminsetgithub: 61113
2013-01-10 08:24:21olofsetmessages: + msg179533
2013-01-09 17:07:00orsenthilsetnosy: + orsenthil

messages: + msg179476
versions: + Python 3.4, - Python 2.7
2013-01-09 14:46:51olofcreate