[bitbake-devel,4/5] fetch2.URI: Support URIs with both query strings and params
Submitted by Olof Johansson on March 10, 2013, 4:22 p.m.
|
Patch ID: 45843
Details
Commit Message
@@ -201,6 +201,10 @@ class URI(object):
if not uri:
return
+ # We hijack the URL parameters, since the way bitbake uses
+ # them are not quite RFC compliant.
+ uri, param_str = (uri.split(";", 1) + [None])[:2]
+
urlp = urlparse.urlparse(uri)
self.scheme = urlp.scheme
@@ -235,17 +239,7 @@ class URI(object):
if urlp.password:
self.userinfo += ':%s' % urlp.password
- # Do support params even for URI schemes that Python's
- # urlparse doesn't support params for.
- path = ''
- param_str = ''
- if not urlp.params:
- path, param_str = (list(urlp.path.split(";", 1)) + [None])[:2]
- else:
- path = urlp.path
- param_str = urlp.params
-
- self.path = urllib.unquote(path)
+ self.path = urllib.unquote(urlp.path)
if param_str:
self.params = self._param_str_split(param_str, ";")
@@ -74,6 +74,24 @@ class URITest(unittest.TestCase):
},
'relative': False
},
+ "http://www.example.org/index.html?qparam1=qvalue1;param2=value2" : {
+ 'uri': 'http://www.example.org/index.html?qparam1=qvalue1;param2=value2',
+ 'scheme': 'http',
+ 'hostname': 'www.example.org',
+ 'port': None,
+ 'hostport': 'www.example.org',
+ 'path': '/index.html',
+ 'userinfo': '',
+ 'username': '',
+ 'password': '',
+ 'params': {
+ 'param2': 'value2'
+ },
+ 'query': {
+ 'qparam1': 'qvalue1'
+ },
+ 'relative': False
+ },
"http://www.example.com:8080/index.html" : {
'uri': 'http://www.example.com:8080/index.html',
'scheme': 'http',
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. Signed-off-by: Olof Johansson <olof.johansson@axis.com> --- lib/bb/fetch2/__init__.py | 16 +++++----------- lib/bb/tests/fetch.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 11 deletions(-)