You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Bruce Atherton <br...@callenish.com> on 2002/08/07 01:34:49 UTC

file:/// URLs using Python's urlparse.urljoin() (was Subversion portability)

At 02:29 PM 8/5/2002 -0500, Karl Fogel wrote:
>Is your workaround below still applicable, or did we solve this some
>other way?  I didn't see anything in the logs indicating that this had
>been applied, nor that the problem had been addressed...

This wasn't a patch to a specific file, it was a hack to add whenever 
someone wanted to use the Python urlparse.urljoin() method and still keep 
the proper file:/// format. Grepping through the Subversion codebase now I 
don't see urljoin() being used anywhere, probably at least in part because 
of the slash-stripping bug.

I guess the hack is still applicable for anyone that wants to write a 
python test that uses urlparse.urljoin() with file:/// URLs in a portable 
way. I don't think there is anything specific that needs to be done about 
it, though. I've changed the subject to make it easier to find in case 
anyone needs it.

Thanks for reminding me about this. It prompted me to send in the patch to 
fix the underlying Python bug.

[hack follows]
 > # FIXME: On at least some versions of Python, a bug in urlparse.urljoin()
 > # strips required slashes out of a "file:" URL. This repairs the damage.
 > # Once Python is fixed to get it right, the required Python version
 > # should be upped and this code should be stripped.
 > import re
 >
 > find_bad_url = re.compile("file:/[^/]")
 > if (find_bad_url.match(urlstring)) is not None:
 > urlstring = urlstring[0:5] + "//" + urlstring[5:]