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.
This commit is contained in:
Thomas Haller 2021-07-16 09:36:49 +02:00
parent 17bdd3a40d
commit fb3e6cb0dc
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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;