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

33 lines
1.2 KiB
Diff

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