summaryrefslogtreecommitdiffstats
path: root/lib/bb/fetch2/__init__.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2014-05-29 18:17:15 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-05-30 10:20:13 +0100
commitbfd13dfbc4c9f1dd8315002271791b1d9e274989 (patch)
treea1d925f15a609de6781c1c6a78e49deca5fd1989 /lib/bb/fetch2/__init__.py
parent42182e3971c2ab17a17754e651e8943b0177410e (diff)
downloadopenembedded-core-contrib-bfd13dfbc4c9f1dd8315002271791b1d9e274989.tar.gz
fetch2: improve handling of two classes of URL parameter mistakes
Handle the following situations in a URL (e.g. in SRC_URI): * Trailing semicolon in a URL - this is now ignored. * Parameter specified with no value (no equals sign). This still produces an error, but at least it is MalformedUrl with a proper message rather than "ValueError: need more than 1 value to unpack". Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/fetch2/__init__.py')
-rw-r--r--lib/bb/fetch2/__init__.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index f571fc45e6..dcada12ead 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -56,8 +56,11 @@ class BBFetchException(Exception):
class MalformedUrl(BBFetchException):
"""Exception raised when encountering an invalid url"""
- def __init__(self, url):
- msg = "The URL: '%s' is invalid and cannot be interpreted" % url
+ def __init__(self, url, message=''):
+ if message:
+ msg = message
+ else:
+ msg = "The URL: '%s' is invalid and cannot be interpreted" % url
self.url = url
BBFetchException.__init__(self, msg)
self.args = (url,)
@@ -371,8 +374,11 @@ def decodeurl(url):
p = {}
if parm:
for s in parm.split(';'):
- s1, s2 = s.split('=')
- p[s1] = s2
+ if s:
+ if not '=' in s:
+ raise MalformedUrl(url, "The URL: '%s' is invalid: parameter %s does not specify a value (missing '=')" % (url, s))
+ s1, s2 = s.split('=')
+ p[s1] = s2
return type, host, urllib.unquote(path), user, pswd, p