summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2022-12-10 21:04:32 +0100
committerAntónio Fernandes <antoniof@gnome.org>2023-01-08 12:45:40 +0000
commit1a66579fb9fb284f927631a172c507819e92833b (patch)
tree217ce59c3748f66a11c461c8713c3d153cd09f94
parent0e558d6c0530a296b7e65c1f4158e253823ea2be (diff)
downloadnautilus-1a66579fb9fb284f927631a172c507819e92833b.tar.gz
error-reporting: Handle G_IO_ERROR_INVALID_ARGUMENT on rename
G_IO_ERROR_INVALID_ARGUMENT was not handled when renaming a file on a Samba/CIFS share, using invalid characters. As this behaviour is very similar to what happens when using an invalid character on vfat or exfat filesystems, merge it into the G_IO_ERROR_INVALID_FILENAME case. See https://en.wikipedia.org/wiki/Filename#Comparison_of_filename_limitations
-rw-r--r--src/nautilus-error-reporting.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/nautilus-error-reporting.c b/src/nautilus-error-reporting.c
index 655730a9c..12fa92936 100644
--- a/src/nautilus-error-reporting.c
+++ b/src/nautilus-error-reporting.c
@@ -271,15 +271,22 @@ nautilus_report_error_renaming_file (NautilusFile *file,
}
break;
+ case G_IO_ERROR_INVALID_ARGUMENT:
case G_IO_ERROR_INVALID_FILENAME:
{
- if (strchr (new_name, '/') != NULL)
+ const char *invalid_chars = FAT_FORBIDDEN_CHARACTERS;
+
+ for (guint i = 0; i < strlen (invalid_chars); i++)
{
- message = g_strdup_printf (_("The name “%s” is not valid because it contains the character “/”. "
- "Please use a different name."),
- truncated_new_name);
+ if (strchr (new_name, invalid_chars[i]) != NULL)
+ {
+ message = g_strdup_printf (_("The name “%s” is not valid because it contains the character “%c”. "
+ "Please use a different name."),
+ truncated_new_name, invalid_chars[i]);
+ break;
+ }
}
- else
+ if (message == NULL)
{
message = g_strdup_printf (_("The name “%s” is not valid. "
"Please use a different name."),