updateiconcache: ignore icons from unknown directories

Do not add images from unknown icon-theme directories to the cache.

Files that cannot be associated with a valid icon theme subdirectory
should not be cached with the fallback directory index. Skipping them
avoids listing random images from invalid locations in icon-theme.cache.

Ported-from: Debian gtk+2.0 060_ignore-random-icons.patch
This commit is contained in:
Daemonratte 2026-04-30 12:03:08 +02:00
commit cd7eac91d3

View file

@ -673,18 +673,18 @@ scan_directory (const gchar *base_path,
flags |= HAS_SUFFIX_XPM;
else if (g_str_has_suffix (name, ".icon"))
flags |= HAS_ICON_FILE;
if (flags == 0)
continue;
basename = g_strdup (name);
dot = strrchr (basename, '.');
*dot = '\0';
image = g_hash_table_lookup (dir_hash, basename);
if (!image)
{
if (!dir_added)
if (!dir_added)
{
dir_added = TRUE;
if (subdir)
@ -693,19 +693,19 @@ scan_directory (const gchar *base_path,
directories = g_list_append (directories, g_strdup (subdir));
}
else
dir_index = 0xffff;
continue;
}
image = g_new0 (Image, 1);
image->dir_index = dir_index;
g_hash_table_insert (dir_hash, g_strdup (basename), image);
}
image->flags |= flags;
maybe_cache_image_data (image, path);
maybe_cache_icon_data (image, path);
g_free (basename);
}
@ -716,7 +716,7 @@ scan_directory (const gchar *base_path,
/* Move dir into the big file hash */
g_hash_table_foreach_remove (dir_hash, foreach_remove_func, files);
g_hash_table_destroy (dir_hash);
return directories;