summaryrefslogtreecommitdiffstats
path: root/lib/bb/fetch2
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-06-28 11:34:20 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-06-28 12:39:47 +0100
commitce0579dc256251e523c6330641f98b9f5a0e5761 (patch)
tree5276fe7305b09c6714ae3d2f7d2666b0a9ebef09 /lib/bb/fetch2
parent2b1311e21172847b6a86cfb21a84fd00e4ab1ac5 (diff)
downloadbitbake-ce0579dc256251e523c6330641f98b9f5a0e5761.tar.gz
fetch2: Revert the regexp removal for the type field and instead anchor regexp
People are using regexps in the url type field so we need to preserve this bitbake behaviour. To address the issues with https:// urls mapping badly to file:// urls we anchor the regexp if its not already anchored. There should be no expressions in the wild which would break with this change. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/fetch2')
-rw-r--r--lib/bb/fetch2/__init__.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index a38cb8ffb..52e12a0a9 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -193,6 +193,11 @@ def uri_replace(ud, uri_find, uri_replace, replacements, d):
result_decoded = ['', '', '', '', '', {}]
for loc, i in enumerate(uri_find_decoded):
result_decoded[loc] = uri_decoded[loc]
+ regexp = i
+ if loc == 0 and regexp and not regexp.endswith("$"):
+ # Leaving the type unanchored can mean "https" matching "file" can become "files"
+ # which is clearly undesirable.
+ regexp += "$"
if loc == 5:
# Handle URL parameters
if i:
@@ -203,20 +208,14 @@ def uri_replace(ud, uri_find, uri_replace, replacements, d):
# Overwrite any specified replacement parameters
for k in uri_replace_decoded[loc]:
result_decoded[loc][k] = uri_replace_decoded[loc][k]
- elif loc == 0:
- # Principle of least surprise. We could end up with https matching against http and
- # generating "files://" urls if we use the regexp engine below.
- if i != uri_decoded[loc]:
- return None
- result_decoded[loc] = uri_replace_decoded[loc]
- elif (re.match(i, uri_decoded[loc])):
+ elif (re.match(regexp, uri_decoded[loc])):
if not uri_replace_decoded[loc]:
result_decoded[loc] = ""
else:
for k in replacements:
uri_replace_decoded[loc] = uri_replace_decoded[loc].replace(k, replacements[k])
- #bb.note("%s %s %s" % (i, uri_replace_decoded[loc], uri_decoded[loc]))
- result_decoded[loc] = re.sub(i, uri_replace_decoded[loc], uri_decoded[loc])
+ #bb.note("%s %s %s" % (regexp, uri_replace_decoded[loc], uri_decoded[loc]))
+ result_decoded[loc] = re.sub(regexp, uri_replace_decoded[loc], uri_decoded[loc])
if loc == 2:
# Handle path manipulations
basename = None