Doubled slashes in master_sites

Ryan Schmidt ryandesign at macports.org
Sun Dec 9 23:59:22 PST 2007


It's a common occurrence that you'll see something like this while  
fetching a port:

$ sudo port install python24
--->  Fetching python24
--->  Attempting to fetch Python-2.4.4.tar.bz2 from http:// 
www.python.org//ftp/python/2.4.4/
^C
$

Note the double slash after the hostname, which should just be a  
single slash. This is not a major problem, because the server still  
responds and delivers the desired file. But it's not 100% correct,  
and I'm a stickler for perfection, so here we go.

The problem comes about because of these definitions in the portfile:

homepage        http://www.python.org/
master_sites    ${homepage}/ftp/python/${version}/

The homepage ends with a slash, as it definitely should. But then the  
port author has defined master_sites with a slash after the homepage  
variable, which should not have been done. The correct definiton for  
master_sites would be:

master_sites    ${homepage}ftp/python/${version}/

I fix this in open ports when I see it and send patches to the  
maintainers of closed ports. In response to one such patch, Markus  
suggested that MacPorts base should automatically fix this. I suppose  
there is precedent, insofar as MacPorts will fix master_sites to end  
with a slash, if it does not already.

I'm not sure if I'd be in favor of automated stripping of doubled  
slashes within URLs. It introduces a bit of magic into the  
master_sites variable, and I think magic should be avoided. And  
theoretically, a server could behave differently depending on the  
number of slashes. In practice, though, Apache collapses doubled  
slashes into a single one, and I don't know of any sites that would  
rely on double slashes in their download URLs.

What do you all think?



More information about the macports-dev mailing list