From 250088ed7ef304bb65845f70ee059bad48bff64c Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 12 2019 11:55:06 +0000 Subject: Fix non-ascii strings in xmlrpc requests library refuse to upload non-latin-1 strings, convert data to utf-8 before passing to library. Fixes: https://pagure.io/koji/issue/1219 --- diff --git a/koji/__init__.py b/koji/__init__.py index 05c8e5f..967b84d 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -2389,6 +2389,17 @@ class ClientSession(object): else: handler = self.baseurl request = dumps(args, name, allow_none=1) + try: + request.encode('latin-1') + except UnicodeEncodeError: + # if string is not converted to UTF, requests will raise an error + # on identical check before sending data + # py3 string throws UnicodeEncodeError + request = request.encode('utf-8') + except UnicodeDecodeError: + # py2 string throws UnicodeDecodeError, but it is already meant + # to sent as-is + pass headers = [ # connection class handles Host ('User-Agent', 'koji/1'),