From 9f8c7398b4e4104dd3ad5183903642897ef6c85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20H=C3=BCwe?= Date: Thu, 16 Jul 2009 12:07:14 +0000 Subject: [PATCH] - fixed #521895 ('osc vc crashes'): only use and store proper apiurls this means no trailing slashes etc. --- osc/conf.py | 4 +++- osc/core.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/osc/conf.py b/osc/conf.py index fc903868..2e4ebd93 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -157,7 +157,8 @@ def parse_apisrv_url(scheme, apisrv): if apisrv.startswith('http://') or apisrv.startswith('https://'): return urlparse.urlsplit(apisrv)[0:2] elif scheme != None: - return scheme, apisrv + # the split/join is needed to get a proper url (e.g. without a trailing slash) + return urlparse.urlsplit(urljoin(scheme, apisrv))[0:2] else: from urllib2 import URLError msg = 'invalid apiurl \'%s\' (specify the protocol (http:// or https://))' % apisrv @@ -362,6 +363,7 @@ def get_config(override_conffile = None, raise oscerr.ConfigError(msg, conffile) config = dict(cp.items('general', raw=1)) + config['apiurl'] = urljoin(*parse_apisrv_url(None, config['apiurl'])) # backward compatibility if config.has_key('apisrv'): diff --git a/osc/core.py b/osc/core.py index 8d952905..a7504807 100755 --- a/osc/core.py +++ b/osc/core.py @@ -3283,10 +3283,12 @@ def store_read_package(dir): def store_read_apiurl(dir): fname = os.path.join(dir, store, '_apiurl') try: - apiurl = open(fname).readlines()[0].strip() + url = open(fname).readlines()[0].strip() + # this is needed to get a proper apiurl + # (former osc versions may stored an apiurl with a trailing slash etc.) + apiurl = conf.urljoin(*conf.parse_apisrv_url(None, url)) except: apiurl = conf.config['apiurl'] - #store_write_apiurl(dir, apiurl) return apiurl def store_write_string(dir, file, string):