1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
From: Khalid Abu Shawarib <khalid.shawarib@gmail.com>
Date: Thu, 23 Oct 2025 02:00:57 +0300
Subject: file-utilities: Match home directory with existing function
Current function is too literal and would fail when having extra slash
at the end of the path. Thus allowing home to be used as a templates
folder, causing nautilus to be a massive performance hog.
Bug: https://gitlab.gnome.org/GNOME/nautilus/-/issues/4014
Bug-Debian: https://bugs.debian.org/1118444
Bug-Debian: https://bugs.debian.org/1118564
Origin: upstream, 50.0, commit:272a2d4f304f62466ce3fe56bb60270fa9c815a7
---
src/nautilus-file-utilities.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/nautilus-file-utilities.c b/src/nautilus-file-utilities.c
index dba3061..d8c4cd5 100644
--- a/src/nautilus-file-utilities.c
+++ b/src/nautilus-file-utilities.c
@@ -147,12 +147,17 @@ nautilus_get_home_directory_uri (void)
gboolean
nautilus_should_use_templates_directory (void)
{
- const char *dir;
- gboolean res;
+ const char *templates_dir = g_get_user_special_dir (G_USER_DIRECTORY_TEMPLATES);
- dir = g_get_user_special_dir (G_USER_DIRECTORY_TEMPLATES);
- res = dir && (g_strcmp0 (dir, g_get_home_dir ()) != 0);
- return res;
+ if (templates_dir == NULL || *templates_dir == '\0')
+ {
+ return FALSE;
+ }
+
+ g_autoptr (GFile) templates_location = g_file_new_for_path (templates_dir);
+
+ return !nautilus_is_home_directory (templates_location) &&
+ !nautilus_is_root_directory (templates_location);
}
char *
|