From 371dbaa6d0f7b5f86bfdeb6aef9a47b1ec431029 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Wed, 4 Mar 2009 15:01:34 +0000
Subject: [PATCH] Even though we detect a Redirect code not always we can rely
 that server will send a correct location header. Be more robust and add a
 basic check.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25868 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Wizard/Tool/WizardTool.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/product/ERP5Wizard/Tool/WizardTool.py b/product/ERP5Wizard/Tool/WizardTool.py
index 4253acbbd4..651a89d186 100644
--- a/product/ERP5Wizard/Tool/WizardTool.py
+++ b/product/ERP5Wizard/Tool/WizardTool.py
@@ -354,14 +354,15 @@ class WizardTool(BaseTool):
       if f.code> 300 and f.code <400:
         # adjust return url which my contain proxy URLs as arguments
         location = metadata.getheader('location')
-        parsed_url = list(urlparse(location))
-        local_site_url_prefix = urllib.quote('%s/portal_wizard/proxy' \
-                                              %self.getPortalObject().absolute_url())
-        remote_url_parsed = urlparse(self.getServerUrl())
-        remote_site_url_prefix = '%s://%s/kb' %(remote_url_parsed[0], remote_url_parsed[1])
-        # fix arguments for returned location URL
-        parsed_url[4] = parsed_url[4].replace(local_site_url_prefix, remote_site_url_prefix)
-        response['location'] = urlunparse(parsed_url)
+        if location is not None:
+          parsed_url = list(urlparse(location))
+          local_site_url_prefix = urllib.quote('%s/portal_wizard/proxy' \
+                                                %self.getPortalObject().absolute_url())
+          remote_url_parsed = urlparse(self.getServerUrl())
+          remote_site_url_prefix = '%s://%s/kb' %(remote_url_parsed[0], remote_url_parsed[1])
+          # fix arguments for returned location URL
+          parsed_url[4] = parsed_url[4].replace(local_site_url_prefix, remote_site_url_prefix)
+          response['location'] = urlunparse(parsed_url)
 
       response.setStatus(f.code, f.msg)
       response.setHeader('content-type', metadata.getheader('content-type'))
-- 
2.30.9