From 2d0b0d44e1ce02e3ebada35c9600e975e3d1f254 Mon Sep 17 00:00:00 2001 From: roentgen Date: Tue, 17 Oct 2023 18:28:00 +0300 Subject: [PATCH] README: Made sure characters are escaped correctly Nautilus supports toasts as a way to give feedback to the user about how certain operations finished. However, the character '&' was not escaped correctly, causing toasts for certain file names to be empty. To fix this, I added '&' to the list of unsupported XML characters and made sure it is escaped correctly. https://gitlab.gnome.org/GNOME/nautilus/-/issues/3085 --- src/nautilus-file-operations.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c index ffae9316dc..2ce0a7961a 100644 --- a/src/nautilus-file-operations.c +++ b/src/nautilus-file-operations.c @@ -1004,6 +1004,10 @@ has_invalid_xml_char (char *str) { c = g_utf8_get_char (str); /* characters XML permits */ + + if (c == 0x26) + return TRUE; + if (!(c == 0x9 || c == 0xA || c == 0xD || @@ -1059,7 +1063,7 @@ get_basename (GFile *file) } else { - name = g_uri_escape_string (basename, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE); + name = g_uri_escape_string (basename, "!$'()*+,;=:@/ ", TRUE); g_free (basename); } } @@ -1068,8 +1072,8 @@ get_basename (GFile *file) if (has_invalid_xml_char (name)) { tmp = name; - name = g_uri_escape_string (name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE); - g_free (tmp); + name = g_uri_escape_string (tmp, "!$'()*+,;=:@/ ", TRUE); + g_free(tmp); } /* Finally, if the string is too long, truncate it. */ -- GitLab