Blame SOURCES/0022-hawkey-surrogateescape-error-handler-to-decode-UTF-8-strings-RhBug1893176.patch

3dc890
From 263eee36afc0ae5c8f342f4b61038e91ee942b21 Mon Sep 17 00:00:00 2001
3dc890
From: Marek Blaha <mblaha@redhat.com>
3dc890
Date: Thu, 22 Apr 2021 15:19:26 +0200
3dc890
Subject: [PATCH] hawkey: surrogateescape error handler to decode UTF-8 strings (RhBug:1893176)
3dc890
3dc890
This ensures that libdnf does not raise UnicodeDecodeError when
3dc890
accessing package with non UTF-8 file names.
3dc890
3dc890
= changelog =
3dc890
msg:           DNF does not fail on non UTF-8 file names in a package
3dc890
type:          bugfix
3dc890
resolves:      https://bugzilla.redhat.com/show_bug.cgi?id=1893176
3dc890
---
3dc890
 python/hawkey/iutil-py.cpp | 2 +-
3dc890
 1 file changed, 1 insertion(+), 1 deletion(-)
3dc890
3dc890
diff --git a/python/hawkey/iutil-py.cpp b/python/hawkey/iutil-py.cpp
3dc890
index 56ccafd..57bef57 100644
3dc890
--- a/python/hawkey/iutil-py.cpp
3dc890
+++ b/python/hawkey/iutil-py.cpp
3dc890
@@ -285,7 +285,7 @@ strlist_to_pylist(const char **slist)
3dc890
         return NULL;
3dc890
 
3dc890
     for (const char **iter = slist; *iter; ++iter) {
3dc890
-        UniquePtrPyObject str(PyUnicode_FromString(*iter));
3dc890
+        UniquePtrPyObject str(PyUnicode_DecodeUTF8(*iter, strlen(*iter), "surrogateescape"));
3dc890
         if (!str)
3dc890
             return NULL;
3dc890
         int rc = PyList_Append(list.get(), str.get());
3dc890
--
3dc890
libgit2 1.0.1
3dc890