Handle % characters in URLs

If there is a % character in the path to a file / directory, we need to
properly encode it when creating the repo web URL or the link won't
work. Thanks to Khem Raj for reporting this.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2014-05-12 14:15:31 +01:00
parent f7fa15dd36
commit bbbf5e9939

View File

@ -143,6 +143,11 @@ class LayerBranch(models.Model):
else: else:
branchname = self.branch.name branchname = self.branch.name
url = base_url.replace('%branch%', branchname) url = base_url.replace('%branch%', branchname)
# If there's a % in the path (e.g. a wildcard bbappend) we need to encode it
if extra_path:
extra_path = extra_path.replace('%', '%25')
if '%path%' in base_url: if '%path%' in base_url:
if extra_path: if extra_path:
url = re.sub(r'\[([^\]]*%path%[^\]]*)\]', '\\1', url) url = re.sub(r'\[([^\]]*%path%[^\]]*)\]', '\\1', url)