richardphibel / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

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

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