summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index a38cb8ffbe..52e12a0a9b 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -193,6 +193,11 @@ def uri_replace(ud, uri_find, uri_replace, replacements, d):
193 result_decoded = ['', '', '', '', '', {}] 193 result_decoded = ['', '', '', '', '', {}]
194 for loc, i in enumerate(uri_find_decoded): 194 for loc, i in enumerate(uri_find_decoded):
195 result_decoded[loc] = uri_decoded[loc] 195 result_decoded[loc] = uri_decoded[loc]
196 regexp = i
197 if loc == 0 and regexp and not regexp.endswith("$"):
198 # Leaving the type unanchored can mean "https" matching "file" can become "files"
199 # which is clearly undesirable.
200 regexp += "$"
196 if loc == 5: 201 if loc == 5:
197 # Handle URL parameters 202 # Handle URL parameters
198 if i: 203 if i:
@@ -203,20 +208,14 @@ def uri_replace(ud, uri_find, uri_replace, replacements, d):
203 # Overwrite any specified replacement parameters 208 # Overwrite any specified replacement parameters
204 for k in uri_replace_decoded[loc]: 209 for k in uri_replace_decoded[loc]:
205 result_decoded[loc][k] = uri_replace_decoded[loc][k] 210 result_decoded[loc][k] = uri_replace_decoded[loc][k]
206 elif loc == 0: 211 elif (re.match(regexp, uri_decoded[loc])):
207 # Principle of least surprise. We could end up with https matching against http and
208 # generating "files://" urls if we use the regexp engine below.
209 if i != uri_decoded[loc]:
210 return None
211 result_decoded[loc] = uri_replace_decoded[loc]
212 elif (re.match(i, uri_decoded[loc])):
213 if not uri_replace_decoded[loc]: 212 if not uri_replace_decoded[loc]:
214 result_decoded[loc] = "" 213 result_decoded[loc] = ""
215 else: 214 else:
216 for k in replacements: 215 for k in replacements:
217 uri_replace_decoded[loc] = uri_replace_decoded[loc].replace(k, replacements[k]) 216 uri_replace_decoded[loc] = uri_replace_decoded[loc].replace(k, replacements[k])
218 #bb.note("%s %s %s" % (i, uri_replace_decoded[loc], uri_decoded[loc])) 217 #bb.note("%s %s %s" % (regexp, uri_replace_decoded[loc], uri_decoded[loc]))
219 result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc]) 218 result_decoded[loc] = re.sub(regexp, uri_replace_decoded[loc], uri_decoded[loc])
220 if loc == 2: 219 if loc == 2:
221 # Handle path manipulations 220 # Handle path manipulations
222 basename = None 221 basename = None