allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 03/04: [#8382] encoding fixes in import_api used by trac wiki importer
Date Thu, 31 Dec 2020 22:29:46 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8382
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 3095533e745bf9152ac54c74e610ef18d32245ff
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
AuthorDate: Thu Dec 31 16:48:15 2020 -0500

    [#8382] encoding fixes in import_api used by trac wiki importer
---
 Allura/allura/lib/import_api.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/Allura/allura/lib/import_api.py b/Allura/allura/lib/import_api.py
index 481264e..3560f38 100644
--- a/Allura/allura/lib/import_api.py
+++ b/Allura/allura/lib/import_api.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import
 import six.moves.urllib.request
 import six.moves.urllib.parse
 import six.moves.urllib.error
-import hmac
-import hashlib
 import json
 import logging
-from datetime import datetime
+
+from allura.lib.utils import urlencode
 
 log = logging.getLogger(__name__)
 
@@ -50,14 +49,14 @@ class AlluraImportApiClient(object):
 
         while True:
             try:
-                result = six.moves.urllib.request.urlopen(url, six.moves.urllib.parse.urlencode(params))
+                result = six.moves.urllib.request.urlopen(url, six.ensure_binary(urlencode(params)))
                 resp = result.read()
                 return json.loads(resp)
             except six.moves.urllib.error.HTTPError as e:
                 e.msg += ' ({0})'.format(url)
                 if self.verbose:
                     error_content = e.read()
-                    e.msg += '. Error response:\n' + error_content
+                    e.msg += '. Error response:\n' + six.ensure_text(error_content)
                 raise e
             except (six.moves.urllib.error.URLError, IOError):
                 if self.retry:


Mime
View raw message