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.

Title: urlparse should parse mailto: URL headers as query parameters
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.4
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.

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 <> 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("")
ParseResult(scheme='mailto', netloc='',
path='', 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 "" 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

ParseResult(scheme='mailto', netloc='', path='', 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("")
ParseResult(scheme='mailto', netloc='', path='', params='', query='subject=hi', fragment='')

So, I am closing this bug as won't fix.
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