From e03587f9b02bc317187b8882cee488d2e5b98cf3 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 16 Jul 2021 09:36:49 +0200 Subject: [PATCH] libnm: use nm_ascii_is_ctrl_or_del() in nm_utils_fixup_product_string() to preserve UTF-8 On architectures where "char" is signed, the check "ch < ' '" is also TRUE for characters greater than 127 (that is, UTF-8 characters). Let's preserve valid UTF-8 characters and don't clear them. Also note that already before we filtered out invalid UTF-8 sequences, so if we encounter here a character > 127, it is part of a valid UTF-8 sequence. (cherry picked from commit fb3e6cb0dc68c1a3a89dd8a64946ecd26e545a64) --- src/libnm-client-impl/nm-libnm-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libnm-client-impl/nm-libnm-utils.c b/src/libnm-client-impl/nm-libnm-utils.c index 045dc6a5b7..671466cf93 100644 --- a/src/libnm-client-impl/nm-libnm-utils.c +++ b/src/libnm-client-impl/nm-libnm-utils.c @@ -166,7 +166,7 @@ _fixup_string(const char * desc, in_paren = TRUE; else if (*p == ')') in_paren = FALSE; - else if (NM_IN_SET(*p, '_', ',') || *p < ' ' || in_paren) { + else if (NM_IN_SET(*p, '_', ',') || nm_ascii_is_ctrl_or_del(*p) || in_paren) { /* pass */ } else continue;