[Python-checkins] CVS: python/dist/src/Lib urlparse.py,1.26,1.27
Fred L. Drake
python-dev@python.org
Thu, 04 Jan 2001 21:54:43 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv4905/Lib
Modified Files:
urlparse.py
Log Message:
urlunparse(): Do not add a leading slash to the path if it is empty.
urljoin(): Make this conform to RFC 1808 for all examples given in that
RFC (both "Normal" and "Abnormal"), so long as that RFC does
not conflict the older RFC 1630, which also specified
relative URL resolution.
This closes SF bug #110832 (Jitterbug PR#194).
Index: urlparse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urlparse.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** urlparse.py 2000/12/19 16:48:13 1.26
--- urlparse.py 2001/01/05 05:54:41 1.27
***************
*** 115,119 ****
(the draft states that these are equivalent)."""
if netloc or (scheme in uses_netloc and url[:2] == '//'):
! if url[:1] != '/': url = '/' + url
url = '//' + (netloc or '') + url
if scheme:
--- 115,119 ----
(the draft states that these are equivalent)."""
if netloc or (scheme in uses_netloc and url[:2] == '//'):
! if url and url[:1] != '/': url = '/' + url
url = '//' + (netloc or '') + url
if scheme:
***************
*** 132,135 ****
--- 132,137 ----
if not base:
return url
+ if not url:
+ return base
bscheme, bnetloc, bpath, bparams, bquery, bfragment = \
urlparse(base, '', allow_fragments)
***************
*** 137,142 ****
urlparse(url, bscheme, allow_fragments)
if scheme != bscheme or scheme not in uses_relative:
! return urlunparse((scheme, netloc, path,
! params, query, fragment))
if scheme in uses_netloc:
if netloc:
--- 139,143 ----
urlparse(url, bscheme, allow_fragments)
if scheme != bscheme or scheme not in uses_relative:
! return url
if scheme in uses_netloc:
if netloc:
***************
*** 148,153 ****
params, query, fragment))
if not path:
return urlunparse((scheme, netloc, bpath,
! params, query or bquery, fragment))
segments = bpath.split('/')[:-1] + path.split('/')
# XXX The stuff below is bogus in various ways...
--- 149,158 ----
params, query, fragment))
if not path:
+ if not params:
+ params = bparams
+ if not query:
+ query = bquery
return urlunparse((scheme, netloc, bpath,
! params, query, fragment))
segments = bpath.split('/')[:-1] + path.split('/')
# XXX The stuff below is bogus in various ways...
***************
*** 160,164 ****
n = len(segments) - 1
while i < n:
! if segments[i] == '..' and segments[i-1]:
del segments[i-1:i+1]
break
--- 165,170 ----
n = len(segments) - 1
while i < n:
! if (segments[i] == '..'
! and segments[i-1] not in ('', '..')):
del segments[i-1:i+1]
break
***************
*** 166,170 ****
else:
break
! if len(segments) == 2 and segments[1] == '..' and segments[0] == '':
segments[-1] = ''
elif len(segments) >= 2 and segments[-1] == '..':
--- 172,176 ----
else:
break
! if segments == ['', '..']:
segments[-1] = ''
elif len(segments) >= 2 and segments[-1] == '..':