[Python-bugs-list] [ python-Bugs-581529 ] bug in splituser(host) in urllib
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 11 Aug 2002 08:30:02 -0700
Bugs item #581529, was opened at 2002-07-15 00:36
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=581529&group_id=5470
Category: Python Library
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Chetan Sarva (csarva)
>Assigned to: Jeremy Hylton (jhylton)
Summary: bug in splituser(host) in urllib
Initial Comment:
The splituser() method splits on the very first "@" it encounters
which can lead to inaccurate results in certain cases (i.e. if the
username portion contains an e-mail address). Splitting on the last
"@" in the string will give the desired results every time.
I'm
not very good with regex's so I've given my simple solution as a
sample below:
_userprog = None
def
splituser(host):
"""splituser('user[:passwd]@host[:port]') -->
'user[:passwd]', 'host[:port]'."""
global _userprog
if
_userprog is None:
x = host.rfind('@')
if x != -1:
return
host[:x], host[x+1:]
else:
return None, host
#import re
#_userprog = re.compile('^([^@]*)@(.*)$')
#match = _userprog.match(host)
#if match: return
map(unquote, match.group(1, 2))
return None, host
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2002-08-11 11:30
Message:
Logged In: YES
user_id=33168
Jeremy, how should this be fixed?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=581529&group_id=5470