summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConley Owens <cco3@android.com>2014-01-31 15:03:51 -0800
committerConley Owens <cco3@android.com>2014-01-31 16:06:31 -0800
commit2d0f508648a1e7c073bc897b645a43ee37ff2a40 (patch)
tree3733b3c81b59e0bb5e3c93770233476f2ff2bb73
parent5db69f3f6616ea199a7840f0602b988f8d5504b9 (diff)
downloadgit-repo-2d0f508648a1e7c073bc897b645a43ee37ff2a40.tar.gz
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
-rw-r--r--manifest_xml.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index f2ac77a5..d496337c 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -80,18 +80,20 @@ class _XmlRemote(object):
80 def _resolveFetchUrl(self): 80 def _resolveFetchUrl(self):
81 url = self.fetchUrl.rstrip('/') 81 url = self.fetchUrl.rstrip('/')
82 manifestUrl = self.manifestUrl.rstrip('/') 82 manifestUrl = self.manifestUrl.rstrip('/')
83 p = manifestUrl.startswith('persistent-http') 83 # urljoin will gets confused over quite a few things. The ones we care
84 if p: 84 # about here are:
85 manifestUrl = manifestUrl[len('persistent-'):] 85 # * no scheme in the base url, like <hostname:port>
86 86 # * persistent-https://
87 # urljoin will get confused if there is no scheme in the base url 87 # We handle this by replacing these with obscure protocols
88 # ie, if manifestUrl is of the form <hostname:port> 88 # and then replacing them with the original when we are done.
89 # gopher -> <none>
90 # wais -> persistent-https
89 if manifestUrl.find(':') != manifestUrl.find('/') - 1: 91 if manifestUrl.find(':') != manifestUrl.find('/') - 1:
90 manifestUrl = 'gopher://' + manifestUrl 92 manifestUrl = 'gopher://' + manifestUrl
93 manifestUrl = re.sub(r'^persistent-https://', 'wais://', manifestUrl)
91 url = urllib.parse.urljoin(manifestUrl, url) 94 url = urllib.parse.urljoin(manifestUrl, url)
92 url = re.sub(r'^gopher://', '', url) 95 url = re.sub(r'^gopher://', '', url)
93 if p: 96 url = re.sub(r'^wais://', 'persistent-https://', url)
94 url = 'persistent-' + url
95 return url 97 return url
96 98
97 def ToRemoteSpec(self, projectName): 99 def ToRemoteSpec(self, projectName):