homepage

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 should parse mailto: URL headers as query parameters
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: orsenthil Nosy List: asvetlov, jfinkels, mykmelez, orsenthil, r.david.murray, webwin
Priority: normal Keywords: easy, patch

Created on 2009年08月04日 00:42 by mykmelez, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue6640.patch jfinkels, 2010年09月28日 19:47 Patch which adds 'mailto' scheme to urllib.parse.uses_query list.
Messages (5)
msg91249 - (view) Author: Myk Melez (mykmelez) Date: 2009年08月04日 00:42
RFC 2368 <http://www.ietf.org/rfc/rfc2368.txt> specifies mailto: URLs as
having the following syntax:
 mailtoURL = "mailto:" [ to ] [ headers ]
 to = #mailbox
 headers = "?" header *( "&" header )
 header = hname "=" hvalue
 hname = *urlc
 hvalue = *urlc
The header fields in these URLs are roughly analogous to query
parameters in other URLs, but urlparse treats them as part of the path
(along with the email address):
>>> import urlparse
>>> urlparse.urlparse("mailto:foo@example.com?subject=hi")
ParseResult(scheme='mailto', netloc='',
path='foo@example.com?subject=hi', params='', query='', fragment='')
It should treat them as query parameters instead, which would not only
make it easier to access them but would also make it easier to access
the email address, since one would no longer have to parse headers, if
any, out of the path first.
msg117541 - (view) Author: Jeffrey Finkelstein (jfinkels) * Date: 2010年09月28日 19:47
Adding the 'mailto' scheme to the urllib.parse.uses_query list changes the behavior as described in msg91249. A patch with a test is attached.
Note that this changes the behavior of urllib.parse.urlparse() on 'mailto:' URLs: with this patch, the function returns the "foo@example.com" in the "netloc" named tuple position instead of in the "path" position.
msg117610 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010年09月29日 14:01
Which would be a bug. According to RFC3986 it should be the path. So the change can't be quite so simple as adding mailto to uses_query. Since the query component is defined for generic uris according to the RFC, it sounds like urllib's parser needs some enhancement.
msg186190 - (view) Author: Volodymyr Bezkostnyy (webwin) * Date: 2013年04月07日 10:46
Tested on 3.4
urllib.parse.urlparse("mailto:foo@example.com?subject=hi")
ParseResult(scheme='mailto', netloc='', path='foo@example.com', params='', query='subject=hi', fragment='')
Work as expected.
msg186377 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013年04月09日 05:34
RFC3986 bears the weightage since urlparse aims to satisfy that. As per that, mailto should return the url as path, and current urlparse behaves properly.
$ ./python.exe
Python 3.4.0a0 (default:50164abbfc98+, Apr 8 2013, 22:19:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib.parse
>>> urllib.parse.urlparse("mailto:foo@example.com?subject=hi")
ParseResult(scheme='mailto', netloc='', path='foo@example.com', params='', query='subject=hi', fragment='')
>>>
So, I am closing this bug as won't fix.
History
Date User Action Args
2022年04月11日 14:56:51adminsetgithub: 50889
2013年04月09日 05:35:01orsenthilsetresolution: fixed -> not a bug
2013年04月09日 05:34:52orsenthilsetstatus: open -> closed
resolution: fixed
messages: + msg186377

stage: test needed -> resolved
2013年04月07日 10:46:01webwinsetnosy: + asvetlov, webwin
messages: + msg186190
2013年03月14日 08:01:08ezio.melottisetkeywords: + easy
versions: + Python 3.4, - Python 3.2
2010年09月29日 14:01:26r.david.murraysetversions: - Python 3.1, Python 2.7
nosy: + r.david.murray

messages: + msg117610

type: behavior -> enhancement
2010年09月28日 19:47:50jfinkelssetfiles: + issue6640.patch

nosy: + jfinkels
messages: + msg117541

keywords: + patch
2010年07月11日 09:00:24BreamoreBoysetassignee: orsenthil
stage: test needed

nosy: + orsenthil
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2009年08月04日 00:42:33mykmelezcreate

AltStyle によって変換されたページ (->オリジナル) /