Patchwork [bitbake-devel] fetch2: quote/unquote url paths

login
register
mail settings
Submitter Christopher Larson
Date May 21, 2012, 11:34 p.m.
Message ID <1337643289-21368-1-git-send-email-kergoth@gmail.com>
Download mbox | patch
Permalink /patch/28249/
State Accepted
Commit b1dbc24ebcc4e5100c32568c2c41fd982fb4bcce
Headers show

Comments

Christopher Larson - May 21, 2012, 11:34 p.m.
This ensures we can handle things like %-encoded characters in the path
portion of urls.

Signed-off-by: Christopher Larson <kergoth@gmail.com>
---
 lib/bb/fetch2/__init__.py |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Richard Purdie - May 22, 2012, 1:39 p.m.
On Mon, 2012-05-21 at 16:34 -0700, Christopher Larson wrote:
> This ensures we can handle things like %-encoded characters in the path
> portion of urls.
> 
> Signed-off-by: Christopher Larson <kergoth@gmail.com>
> ---
>  lib/bb/fetch2/__init__.py |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Merged to master, thanks.

Richard

Patch

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index e3ac4d2..dba8797 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -28,6 +28,7 @@  from __future__ import absolute_import
 from __future__ import print_function
 import os, re
 import logging
+import urllib
 import bb.persist_data, bb.utils
 from bb import data
 
@@ -147,14 +148,14 @@  def decodeurl(url):
             s1, s2 = s.split('=')
             p[s1] = s2
 
-    return (type, host, path, user, pswd, p)
+    return type, host, urllib.unquote(path), user, pswd, p
 
 def encodeurl(decoded):
     """Encodes a URL from tokens (scheme, network location, path,
     user, password, parameters).
     """
 
-    (type, host, path, user, pswd, p) = decoded
+    type, host, path, user, pswd, p = decoded
 
     if not path:
         raise MissingParameterError('path', "encoded from the data %s" % str(decoded))
@@ -168,7 +169,7 @@  def encodeurl(decoded):
         url += "@"
     if host and type != "file":
         url += "%s" % host
-    url += "%s" % path
+    url += "%s" % urllib.quote(path)
     if p:
         for parm in p:
             url += ";%s=%s" % (parm, p[parm])