From: Zhang Qiang Date: Wed, 7 Aug 2013 08:27:58 +0000 (+0800) Subject: Support user/password in proxy X-Git-Tag: 0.21~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9add90903339901e134b560deb2d9bf29146269c;p=tools%2Fmic.git Support user/password in proxy If password contains special char ':' which should be replaced with its' quoted char '%3A'. Fixes: #541 Change-Id: I12575208c7c337f0bad3a40bac0988e17b160819 --- diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py index fb01e47..a1022fb 100755 --- a/plugins/backend/zypppkgmgr.py +++ b/plugins/backend/zypppkgmgr.py @@ -389,7 +389,7 @@ class Zypp(BackendPlugin): if proxy: scheme, host, path, parm, query, frag = urlparse.urlparse(proxy) - proxyinfo = host.split(":") + proxyinfo = host.rsplit(":", 1) host = proxyinfo[0] port = "80" @@ -400,8 +400,25 @@ class Zypp(BackendPlugin): host = proxy.rsplit(':', 1)[0] port = proxy.rsplit(':', 1)[1] + # parse user/pass from proxy host + proxyinfo = host.rsplit("@", 1) + if len(proxyinfo) == 2: + host = proxyinfo[1] + # Known Issue: If password contains ":", which should be + # quoted, for example, use '123%3Aabc' instead of 123:abc + userpassinfo = proxyinfo[0].rsplit(":", 1) + if len(userpassinfo) == 2: + proxy_username = userpassinfo[0] + proxy_password = userpassinfo[1] + elif len(userpassinfo) == 1: + proxy_username = userpassinfo[0] + baseurl.setQueryParam ("proxy", host) baseurl.setQueryParam ("proxyport", port) + if proxy_username: + baseurl.setQueryParam ("proxyuser", proxy_username) + if proxy_password: + baseurl.setQueryParam ("proxypass", proxy_password) repo.baseurl[0] = baseurl.asCompleteString() self.repos.append(repo)