You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by di...@apache.org on 2021/01/11 21:56:51 UTC

[allura] 03/04: [#8382] encoding fixes in import_api used by trac wiki importer

This is an automated email from the ASF dual-hosted git repository.

dill0wn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit f1322d804de4269527263bac912dd8a41ff6425f
Author: Dave Brondsema <db...@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: