-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Summary
There is an inconsistency in how icon names are handled during AppImage integration in libappimage. When the original icon name in the desktop file contains spaces, the desktop entry is updated with a sanitized version (spaces replaced with underscores), but the icon file extraction process may not correctly match the sanitized name, leading to missing icons in desktop environments like KDE Plasma.
Reproduction Scenario (MVP Demo)
- Create an AppImage with an icon file in
usr/share/icons/that has a space in its name (e.g.,My App Icon.png). - The corresponding desktop file inside the AppImage should have
Icon=My App Icon(without file extension). - Use
libappimageto integrate this AppImage into the system (e.g., via AppImageLauncher). - The integrated desktop file will have
Icon=appimagekit_<uuid>_My_App_Icon(spaces replaced with underscores). - However, the icon file extraction process may fail to find or correctly handle the original
My App Icon.pngfile due to the mismatch between the sanitized name used for desktop entry and the original name used for file lookup.
Root Cause Analysis
The issue stems from inconsistent handling of icon names in two key locations:
-
Desktop Entry Update (
DesktopEntryEditor::setIcons):- Located in DesktopEntryEditor.cpp
- Uses
StringSanitizer(iconName).sanitizeForPath()to replace spaces with underscores when updating the desktop entry'sIconfield. - Example:
My App Iconbecomesappimagekit_<uuid>_My_App_Icon
-
Icon File Lookup (
ResourcesExtractor::getIconFilePaths):- Located in ResourcesExtractor.cpp
- Uses the original, unsanitized icon name from the desktop file to search for icon files in the AppImage.
- Example: Searches for
My App Iconinusr/share/icons/paths
This mismatch means that if the icon file in the AppImage has spaces in its name, the lookup process may fail to find it, or the extracted file may not match the sanitized name expected by the desktop entry.
Steps to Reproduce
- Create an AppImage with an icon file in
usr/share/icons/that contains spaces in its name. - Ensure the desktop file inside the AppImage references this icon with spaces in the
Icon=field. - Integrate the AppImage using
libappimage(e.g., by running it with AppImageLauncher). - Check the integrated desktop file in
~/.local/share/applications/- it will have a sanitizedIcon=field. - Check the integrated icon files in
~/.local/share/icons/hicolor/*/apps/- they may not match the sanitized name in the desktop file. - The application icon may not appear correctly in desktop environments like KDE Plasma.
Expected Behavior
The icon file lookup and extraction process should use the same sanitized name as used in the desktop entry update, ensuring consistency between the desktop file's Icon field and the actual icon file name.
Actual Behavior
The desktop entry is updated with a sanitized icon name, but the icon file extraction process uses the original, unsanitized name, leading to a mismatch and potentially missing icons.
Proposed Fix
Modify the getIconFilePaths method in ResourcesExtractor to use a sanitized version of the icon name for matching, consistent with how the desktop entry is updated in DesktopEntryEditor::setIcons. This would ensure that both the lookup and the desktop entry reference use the same sanitized name.