diff options
author | Olof Johansson <olof.johansson@axis.com> | 2014-01-20 12:03:23 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-03-24 17:54:46 +0000 |
commit | 57484d68dff378e4f3bd0d3e40b9db02b029feb4 (patch) | |
tree | 189efb3a2ca35052265b94406bbff8586928b23c | |
parent | aca2d14e9350fde58aaaa95cdeff5b051c1d38d3 (diff) | |
download | poky-57484d68dff378e4f3bd0d3e40b9db02b029feb4.tar.gz |
bitbake: fetch2.URI: Support URIs with both query strings and params
There is a case in meta-intel where a SRC_URI contains both a query string and
URI parameter:
https://edc.intel.com/Download.aspx?id=6190;downloadfilename=LIN_IEMGD_1_14_GOLD_2443.tgz
Python's urlparse thought the URI parameters were part of the query parameter
value, but in the bitbake context this is obviously not the case. As bitbake's
usage isn't really RFC compliant, we have to extract and remove the URI parameters
*before* urlparse sees the URI.
(Bitbake rev: c2f27ae4271985b48f957747b6ea372c8699cb49)
Signed-off-by: Olof Johansson <olof.johansson@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 16 | ||||
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 18 |
2 files changed, 23 insertions, 11 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index d9d193ab12..05999607b9 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -208,6 +208,10 @@ class URI(object): | |||
208 | if not uri: | 208 | if not uri: |
209 | return | 209 | return |
210 | 210 | ||
211 | # We hijack the URL parameters, since the way bitbake uses | ||
212 | # them are not quite RFC compliant. | ||
213 | uri, param_str = (uri.split(";", 1) + [None])[:2] | ||
214 | |||
211 | urlp = urlparse.urlparse(uri) | 215 | urlp = urlparse.urlparse(uri) |
212 | self.scheme = urlp.scheme | 216 | self.scheme = urlp.scheme |
213 | 217 | ||
@@ -242,17 +246,7 @@ class URI(object): | |||
242 | if urlp.password: | 246 | if urlp.password: |
243 | self.userinfo += ':%s' % urlp.password | 247 | self.userinfo += ':%s' % urlp.password |
244 | 248 | ||
245 | # Do support params even for URI schemes that Python's | 249 | self.path = urllib.unquote(urlp.path) |
246 | # urlparse doesn't support params for. | ||
247 | path = '' | ||
248 | param_str = '' | ||
249 | if not urlp.params: | ||
250 | path, param_str = (list(urlp.path.split(";", 1)) + [None])[:2] | ||
251 | else: | ||
252 | path = urlp.path | ||
253 | param_str = urlp.params | ||
254 | |||
255 | self.path = urllib.unquote(path) | ||
256 | 250 | ||
257 | if param_str: | 251 | if param_str: |
258 | self.params = self._param_str_split(param_str, ";") | 252 | self.params = self._param_str_split(param_str, ";") |
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 15fe0ab2f2..4fb2178595 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -74,6 +74,24 @@ class URITest(unittest.TestCase): | |||
74 | }, | 74 | }, |
75 | 'relative': False | 75 | 'relative': False |
76 | }, | 76 | }, |
77 | "http://www.example.org/index.html?qparam1=qvalue1;param2=value2" : { | ||
78 | 'uri': 'http://www.example.org/index.html?qparam1=qvalue1;param2=value2', | ||
79 | 'scheme': 'http', | ||
80 | 'hostname': 'www.example.org', | ||
81 | 'port': None, | ||
82 | 'hostport': 'www.example.org', | ||
83 | 'path': '/index.html', | ||
84 | 'userinfo': '', | ||
85 | 'username': '', | ||
86 | 'password': '', | ||
87 | 'params': { | ||
88 | 'param2': 'value2' | ||
89 | }, | ||
90 | 'query': { | ||
91 | 'qparam1': 'qvalue1' | ||
92 | }, | ||
93 | 'relative': False | ||
94 | }, | ||
77 | "http://www.example.com:8080/index.html" : { | 95 | "http://www.example.com:8080/index.html" : { |
78 | 'uri': 'http://www.example.com:8080/index.html', | 96 | 'uri': 'http://www.example.com:8080/index.html', |
79 | 'scheme': 'http', | 97 | 'scheme': 'http', |