Fix persistent-https relative url resolving

Previously, we would remove 'persistent-' then tack it on at the end
if it had been previously found.  However, this would ignore urljoin's
decision on whether or not the second path was relative.  Instead, we
were always assuming it was relative and that we didn't want to use
a different absolute url with a different protocol.

This change handles persistent-https:// in the same way we handled the
absense of an explicit protocol.  The only difference is that this time
instead of temporarily replacing it with 'gopher://', we use 'wais://'.

Change-Id: I6e8ad1eb4b911931a991481717f1ade01315db2a
This commit is contained in:
Conley Owens 2014-01-31 15:03:51 -08:00
parent 5db69f3f66
commit 2d0f508648

View File

@ -80,18 +80,20 @@ class _XmlRemote(object):
def _resolveFetchUrl(self): def _resolveFetchUrl(self):
url = self.fetchUrl.rstrip('/') url = self.fetchUrl.rstrip('/')
manifestUrl = self.manifestUrl.rstrip('/') manifestUrl = self.manifestUrl.rstrip('/')
p = manifestUrl.startswith('persistent-http') # urljoin will gets confused over quite a few things. The ones we care
if p: # about here are:
manifestUrl = manifestUrl[len('persistent-'):] # * no scheme in the base url, like <hostname:port>
# * persistent-https://
# urljoin will get confused if there is no scheme in the base url # We handle this by replacing these with obscure protocols
# ie, if manifestUrl is of the form <hostname:port> # and then replacing them with the original when we are done.
# gopher -> <none>
# wais -> persistent-https
if manifestUrl.find(':') != manifestUrl.find('/') - 1: if manifestUrl.find(':') != manifestUrl.find('/') - 1:
manifestUrl = 'gopher://' + manifestUrl manifestUrl = 'gopher://' + manifestUrl
manifestUrl = re.sub(r'^persistent-https://', 'wais://', manifestUrl)
url = urllib.parse.urljoin(manifestUrl, url) url = urllib.parse.urljoin(manifestUrl, url)
url = re.sub(r'^gopher://', '', url) url = re.sub(r'^gopher://', '', url)
if p: url = re.sub(r'^wais://', 'persistent-https://', url)
url = 'persistent-' + url
return url return url
def ToRemoteSpec(self, projectName): def ToRemoteSpec(self, projectName):