1
0
mirror of https://gitlab.gnome.org/GNOME/nautilus synced 2024-07-07 10:51:36 +00:00

vfs-extensions: don't allow whitespaces in extension

Whitespaces in file extensions are not (commonly) used, it's more
likely in cases where a whitespaces occurs after a dot, that the
dot does not indicatie an extension at all.

This change prevents such incorrect extension detections by
checking for whitespaces, and adjusts a self-check test that tested
for the previous behavior.
This commit is contained in:
Peter Eisenmann 2023-10-26 03:28:05 +02:00
parent 530fb19c2e
commit 678836bbfc
2 changed files with 11 additions and 2 deletions

View File

@ -33,8 +33,9 @@
#include "eel-string.h"
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
/**
* eel_filename_get_extension_offset:
@ -65,6 +66,14 @@ eel_filename_get_extension_offset (const char *filename)
return NULL;
}
for (size_t i = 1; end[i] != '\0'; i += 1)
{
if (isspace (end[i]))
{
return NULL;
}
}
if (end != start)
{
if (strcmp (end, ".gz") == 0 ||

View File

@ -9358,7 +9358,7 @@ nautilus_self_check_file_operations (void)
EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo foo", 1, -1, FALSE), "foo foo (copy)");
EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo.txt", 1, -1, FALSE), "foo (copy).txt");
EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo foo.txt", 1, -1, FALSE), "foo foo (copy).txt");
EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo foo.txt txt", 1, -1, FALSE), "foo foo (copy).txt txt");
EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo foo.txt txt", 1, -1, FALSE), "foo foo.txt txt (copy)");
EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo...txt", 1, -1, FALSE), "foo.. (copy).txt");
EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo...", 1, -1, FALSE), "foo... (copy)");
EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo. (copy)", 1, -1, FALSE), "foo. (another copy)");