Skip to content

entry-directories: skip entries whose desktop file id is not valid UTF-8 - #85

Merged
mtwebster merged 1 commit into
linuxmint:masterfrom
Fantu:skip-desktop-files-with-invalid-utf8-names
Aug 18, 2026
Merged

entry-directories: skip entries whose desktop file id is not valid UTF-8#85
mtwebster merged 1 commit into
linuxmint:masterfrom
Fantu:skip-desktop-files-with-invalid-utf8-names

Conversation

@Fantu

@Fantu Fantu commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

The desktop file id is the entry's path relative to the application directory with the separators turned into dashes, so any byte of the file or directory name that is not valid UTF-8 is handed out as-is by gmenu_tree_entry_get_desktop_file_id().

Introspection bindings refuse to convert such a string. The menu applet reads the id for every entry in appUtils.js loadDirectory(), so a single badly named file anywhere under an applications directory makes cjs throw, the exception propagates out of the applet constructor and the applet is never created — the menu button disappears from the panel entirely:

[menu@cinnamon.org]: String from C value is invalid UTF-8 and cannot be safely stored
[menu@cinnamon.org]: Failed to evaluate 'main' function on applet: menu@cinnamon.org/0
loadDirectory@/usr/share/cinnamon/applets/menu@cinnamon.org/appUtils.js:104:46

Reported as Debian #893510 in 2018 and again as #64 here in 2023.

This validates the id before handing it to the callback and skips the entry when it is not valid UTF-8, logging the offending path so it can be found and renamed. Doing it here rather than at load time also covers the case where the file name is fine but one of the directories leading to it is not — that breaks the applet just the same.

Testing

Tested on Debian unstable with Cinnamon 6.6.9, rebuilding libcinnamon-menu-3-0 6.6.0 with the change. Two cases, a .desktop file with a 0xE9 byte in its name and a correctly named file inside a directory with a 0xE9 byte in its name:

before after
either case menu applet not created, no menu button in the panel 111 apps in 12 categories, same as a healthy system, plus Ignoring "…": its name is not valid UTF-8

The desktop file id is the entry's path relative to the application
directory, with the separators turned into dashes, so any byte of the
file or directory name that is not valid UTF-8 is handed out as-is by
gmenu_tree_entry_get_desktop_file_id().

Introspection bindings refuse to convert such a string. In Cinnamon the
menu applet reads the id for every entry in appUtils.js loadDirectory(),
so a single badly named file anywhere under an applications directory
makes cjs throw "String from C value is invalid UTF-8 and cannot be
safely stored", the exception propagates out of the applet constructor,
and the applet is never created: the menu button disappears from the
panel entirely. Reported as https://bugs.debian.org/893510 in 2018 and
again as linuxmint#64 in 2023.

Validate the id before handing it to the callback and skip the entry
when it is not valid UTF-8, logging the offending path so it can be
found and renamed. Doing it here rather than at load time also covers
the case where the file name is fine but one of the directories leading
to it is not.

Assisted-by: Claude Code:claude-opus-5
@mtwebster
mtwebster merged commit 683df09 into linuxmint:master Aug 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants