diff options
author | Riku Voipio <riku.voipio@linaro.org> | 2020-08-17 14:17:34 +0300 |
---|---|---|
committer | Benjamin Copeland <ben.copeland@linaro.org> | 2020-08-19 13:29:39 +0000 |
commit | 54ee55949a84135ad0c08e92338204094ccef2e7 (patch) | |
tree | 5f448e1ca4fb7bb97d9d8dc4f41c688280f2d4cf | |
parent | e54f48f6eeddd3de8d7a55e8ee5bfb90b42fbeae (diff) | |
download | linaro-license-protection-54ee55949a84135ad0c08e92338204094ccef2e7.tar.gz |
fix direct url references
Fixes direct reference like:
http://localhost:8080/components/kernel/linaro-edk2/latest/x.txt
and thus also wildcards on latest:
http://localhost:8080/components/kernel/linaro-edk2/latest/startup-qemu-*.nsh
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Change-Id: Ia95dbaa3f715dfe604f01b43776dbba9f26147ea
Reviewed-on: https://review.linaro.org/c/infrastructure/linaro-license-protection/+/36170
Reviewed-by: Kelley Spoon <kelley.spoon@linaro.org>
-rw-r--r-- | license_protected_downloads/common.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/license_protected_downloads/common.py b/license_protected_downloads/common.py index f004dd7..1398d25 100644 --- a/license_protected_downloads/common.py +++ b/license_protected_downloads/common.py @@ -177,7 +177,7 @@ def s3_replace_latest(url, bucket=None): key = boto.s3.key.Key(bucket, s3path) # if there's no key already, there's no .s3_linked_from, so we're done here if key is None: - return url + return url try: redir_loc = key.get_contents_as_string().strip() # .s3_linked_from is referencing itself? Should return original url @@ -185,7 +185,9 @@ def s3_replace_latest(url, bucket=None): return url # scrub the s3 prefix new_url = re.sub("^%s" % settings.S3_PREFIX_PATH, '', redir_loc) - new_url += m.group('target') + # reconstruct the url + if m.group('target') != "": + new_url = "%s/%s" % (new_url, m.group('target')) return new_url except: # problem gettings contents, so stop trying to intercept the request |