[issue22118] urljoin fails with messy relative URLs

Mike Lissner report at bugs.python.org
Fri Aug 1 15:59:11 CEST 2014


Mike Lissner added the comment:

FWIW, the workaround that I've just created for this problem is this:

u = 'https://www.appeals2.az.gov/../Decisions/CR20130096OPN.pdf'
# Split the url and rejoin it, nuking any '/..' patterns at the
# beginning of the path.
s = urlsplit(u)
urlunsplit(s[:2] + (re.sub('^(/\.\.)+', '', s.path),) + s[3:])

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22118>
_______________________________________


More information about the Python-bugs-list mailing list