Bug 440071

Summary: Cannot set image as wallpaper if its file path contains a '#'
Product: [Plasma] plasmashell Reporter: sloppedmail
Component: Image WallpaperAssignee: Marco Martin <notmart>
Status: RESOLVED DUPLICATE    
Severity: normal CC: bugseforuns, kde, kde, nate, plasma-bugs
Priority: NOR    
Version: 5.22.3   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description sloppedmail 2021-07-20 13:06:29 UTC
If an image is located in a NTFS partition and its file path contains a '#', it cannot be selected in the wallpaper menu.


STEPS TO REPRODUCE
1. Create NTFS-Partition
2. Place image in a folder that contains a '#' (e.g.: .../#images/image.png)
3. Add image as wallpaper (right-click desktop -> configure -> add image)


OBSERVED RESULT
The image thumbnail shows up in the list, but cannot be selected. Clicking on said image automatically selects a different (default) image


EXPECTED RESULT
The image should be selectable and appliable


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: Plasma 5.22.3
KDE Frameworks Version: 5.84.0
Qt Version: 5.12.2


ADDITIONAL INFORMATION
* This only seems to occur on images located in NTFS partitions. Ext4 works fine
* Affected images cannot be removed, even after deleting the file
* You can add the same image multiple times
* Duplicates disappear after restarting the program
Comment 1 sloppedmail 2021-07-20 14:05:13 UTC
Appareantly it's NOT just NTFS, as the same thing happens inside my home-directory on a normal ext4 partition (I messed up while testing earlier)

The same issue is also present on the newest stable KDE Neon (tested in a live environment)

Observations:
If a parent-folder has a '#' in it, the image cannot be selected. If the file-name has a '#', it can be selected, but cannot be applied
Comment 2 David Edmundson 2021-07-20 14:24:09 UTC
Some quick notes:

It goes wrong in the config dialog.

/home/david/#foo.jpg

gets saved as:
usersWallpapers=/home/david/foo.jpg

in plasmarc

It strips the "#" character, it doesn't truncate to that point, so it's not treating it as a URL fragment
Comment 3 Kai Uwe Broulik 2021-07-20 15:07:59 UTC
int BackgroundListModel::indexOf(const QString &path) const
{
    for (int i = 0; i < m_packages.size(); i++) {
        // packages will end with a '/', but the path passed in may not
        QString package = m_packages[i].path();
        if (package.endsWith(QChar::fromLatin1('/'))) {
            package.chop(1);
        }
        // remove eventual file:///
        const QString filteredPath = QUrl(path).path();

That obviously fails encoding/decoding
Comment 4 Nate Graham 2022-06-02 19:02:29 UTC
Just fixed in Bug 454692.

*** This bug has been marked as a duplicate of bug 454692 ***