473,320 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

should urlparse return user and pass in separate components?

The urlparse with Python 2.4.3 includes the user and pass in the site
aspect of its parse:
>>scheme, site, path, parms, query, fid = urlparse.urlparse("http://bill:ja***@docs.python.org/lib/module-urlparse.html")
>>site
'bill:ja***@docs.python.org'
I personally would prefer that it be broken down a bit further. What
are existing opinions on this?

Sep 7 '06 #1
4 2656

metaperlI personally would prefer that it be broken down a bit
metaperlfurther. What are existing opinions on this?

I believe there have been noises made in this direction, and not that long
ago. If a backward-compatible way of solving this problem could be worked
out, I imagine this could go in 2.6. If not, such a change would probably
have to wait until 3.0. I'm sure there are plenty of applications in the
wild that rely on the current behavior. You might try searching the bugs
and patches on SF to see if someone's already submitted a patch. If so,
feel free to try it out and add a review comment.

Skip
Sep 7 '06 #2
metaperl wrote:
The urlparse with Python 2.4.3 includes the user and pass in the site
aspect of its parse:
>>>scheme, site, path, parms, query, fid = urlparse.urlparse("http://bill:ja***@docs.python.org/lib/module-urlparse.html")
>>>site
'bill:ja***@docs.python.org'
I personally would prefer that it be broken down a bit further. What
are existing opinions on this?
Here is a function that I wrote to do that. It doesn't do
exactly what you want, but might save you some time.

def spliturl(self, url):
'''
spliturl - method to split composite url into its component parts
ftp://username:pa******@www.domain.com/dav

gets split into:

scheme.............ftp
domain.............www.domain.com
username...........username
password...........password
rootfolder........./dav
port...............None

returns list of 6 strings/None containing above listed variables
'''
parts=urlparse.urlsplit(url)
scheme=parts[0]
usernameandpassword, domain=urllib.splituser(parts[1])
username, password=urllib.splitpasswd(usernameandpassword)
rootfolder, port=urllib.splitport(parts[2])
if port is not None: port=int(port)
return [scheme, domain, username, password, rootfolder, port]

-Larry Bates
Sep 7 '06 #3
Oops, sorry missed something converting from a method to a function:

Here is a function that I wrote to do that. It doesn't do
exactly what you want, but might save you some time.

def spliturl(url):
'''
spliturl - method to split composite url into its component parts
ftp://username:pa******@www.domain.com/dav

gets split into:

scheme.............ftp
domain.............www.domain.com
username...........username
password...........password
rootfolder........./dav
port...............None

returns list of 6 strings/None containing above listed variables
'''
parts=urlparse.urlsplit(url)
scheme=parts[0]
usernameandpassword, domain=urllib.splituser(parts[1])
username, password=urllib.splitpasswd(usernameandpassword)
rootfolder, port=urllib.splitport(parts[2])
if port is not None: port=int(port)
return [scheme, domain, username, password, rootfolder, port]

-Larry Bates

metaperl wrote:
The urlparse with Python 2.4.3 includes the user and pass in the site
aspect of its parse:
>>>scheme, site, path, parms, query, fid = urlparse.urlparse("http://bill:ja***@docs.python.org/lib/module-urlparse.html")
>>>site
'bill:ja***@docs.python.org'
I personally would prefer that it be broken down a bit further. What
are existing opinions on this?
Sep 7 '06 #4
"metaperl" <me******@gmail.comwrites:
The urlparse with Python 2.4.3 includes the user and pass in the site
aspect of its parse:
>scheme, site, path, parms, query, fid = urlparse.urlparse("http://bill:ja***@docs.python.org/lib/module-urlparse.html")
>site
'bill:ja***@docs.python.org'
I personally would prefer that it be broken down a bit further. What
are existing opinions on this?
Module urlparse should be deprecated in Python 2.6, to be replaced
with a new module (or modules) that implements the relevant parts of
RFC 3986 and 3987 (read the python-dev archives for discussion and
several people's first cuts at implementation).

Splitting "userinfo" (the bit before the '@' in
user:pa******@host.com) should be a separate function. Mostly because
RFC 3986 talks a lot about 5-tuples into which ANY URL can be split,
and that splitting process doesn't involve splitting out userinfo. So
it makes sense to have one function do the splitting into RFC 3986
5-tuples, and another split out the userinfo. Also, though, the
userinfo syntax is deprecated, because people use it for semantic
spoofing attacks: people don't understand (or don't notice) that

http://mi***************************...more/stuff.htm

is not a microsoft.com URL. Note that userinfo has always been
illegal in HTTP URLs, and is no longer supported by newer browsers.
So relegating it to a separate function is a good thing, IMO.
John

Sep 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Eric Veltman | last post by:
Hello everyone, I've posted this question before, but got no answer, so I'll try to reformulate the question, maybe it helps :-) By the way, this is not intended as the start of an ASP.NET...
5
by: Al Davis | last post by:
Note: I tried cross-posting this message to several newsgoups, including comp.lang.perl.misc, c.l.p.moderated, comp.infosystems.www.authoring.cgi, comp.lang.javascript and comp.lang.php. Nothing...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
9
by: Weekend | last post by:
Currently, i want to develope a multiple choice exam website. The content of the test is store in an XML file. I want to carry out some function. Could you tell me which programming language should...
2
by: John | last post by:
Hi, I have a data driven application which has some generalized components. So, for reuse, I am building the components so they can be reused in other projects ... it takes almost no extra...
2
by: baret bonden | last post by:
Trying to return a selected listbox item to another form .tried lots of ways; defining public variables and passing those as well as textboxes ..I' m able to display the chosen item on it's form...
7
by: pooba53 | last post by:
I am working with VB .NET 2003. Let's say my main form is called Form1. I have to launch a new form (Form2) that gathers input from the user. How can I pass variable information back to Form1...
3
by: John Nagle | last post by:
Here's a hostile URL that "urlparse.urlparse" seems to have mis-parsed. ====...
2
by: Robert Hancock | last post by:
Python 2.5.2 (r252:60911, Aug 28 2008, 23:51:17) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "<stdin>", line 1, in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.