Bug 454692

Summary: Image wallpaper handling fails if image name contains special chars
Product: [Plasma] plasmashell Reporter: Schlaefer <openmail+kde>
Component: Image WallpaperAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: nate, notmart, qydwhotmail, sloppedmail, this.is.reid, tobiasneisser
Priority: NOR    
Version: 5.24.90   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 5.27
Sentry Crash Report:
Attachments: Issues Image wallpaper files with special chars

Description Schlaefer 2022-06-01 09:40:45 UTC
Created attachment 149372 [details]
Issues Image wallpaper files with special chars

STEPS TO REPRODUCE
1. Have an image file which contains special chars e.g. an "#" ala "test #1.jpg" and try to use with in the Image wallpaper plugin

OBSERVED RESULT

- Adding an image via Drag and Drop onto the wallpaper dialog fails
- Setting the image via "Set as Wallpaper" context menu fails
- Setting an existing image in Image wallpaper fails
- Deleting an existing image in Image wallpaper fails

EXPECTED RESULT

All of the above shouldn't fail.

SOFTWARE/OS VERSIONS
Operating System: EndeavourOS
KDE Plasma Version: 5.24.90
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.4
Kernel Version: 5.18.1-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Graphics Processor: AMD Radeon RX 5500 XT
Comment 1 Fushan Wen 2022-06-01 13:00:12 UTC
Can reproduce
Comment 2 Bug Janitor Service 2022-06-01 15:13:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/1793
Comment 3 Fushan Wen 2022-06-01 15:35:01 UTC
Git commit 9a2657668384a5b2396d3375733d7b8662b99ccc by Fushan Wen.
Committed on 01/06/2022 at 15:14.
Pushed by fusionfuture into branch 'master'.

wallpapers/image: use url argument type in `addUsersWallpaper`

The hash sign # will be converted to % when using string argument type.

M  +2    -2    wallpapers/image/plugin/imagebackend.cpp
M  +1    -1    wallpapers/image/plugin/imagebackend.h

https://invent.kde.org/plasma/plasma-workspace/commit/9a2657668384a5b2396d3375733d7b8662b99ccc
Comment 4 Fushan Wen 2022-06-01 15:35:09 UTC
Git commit 31b7090224770e7879c901433c0423817f285aec by Fushan Wen.
Committed on 01/06/2022 at 15:14.
Pushed by fusionfuture into branch 'master'.

wallpapers/image: use string data type for `image` property

`wallpaper.configuration.Image` has string type, and assigning a string
value from QML to a url in C++ will truncate the string at the hash char.
This changes `image` data type to string to fix the bug.
FIXED-IN: 5.26

M  +1    -1    wallpapers/image/imagepackage/contents/ui/main.qml
M  +5    -5    wallpapers/image/plugin/imagebackend.cpp
M  +3    -3    wallpapers/image/plugin/imagebackend.h

https://invent.kde.org/plasma/plasma-workspace/commit/31b7090224770e7879c901433c0423817f285aec
Comment 5 Fushan Wen 2022-06-01 15:35:17 UTC
Git commit 79e55866472dcd812f8cde4830e89a4bcaf47263 by Fushan Wen.
Committed on 01/06/2022 at 15:14.
Pushed by fusionfuture into branch 'master'.

wallpapers/image: update tests

A new image is added to the default folder.

A  +27   -0    wallpapers/image/plugin/autotests/commontestdata.h     [License: GPL(v2.0+)]
M  +6    -3    wallpapers/image/plugin/autotests/test_imagefinder.cpp
M  +17   -13   wallpapers/image/plugin/autotests/test_imagelistmodel.cpp
M  +28   -24   wallpapers/image/plugin/autotests/test_imageproxymodel.cpp
M  +2    -1    wallpapers/image/plugin/autotests/test_imagesizefinder.cpp
M  +6    -3    wallpapers/image/plugin/autotests/test_packagefinder.cpp
M  +7    -6    wallpapers/image/plugin/autotests/test_packagelistmodel.cpp
M  +2    -1    wallpapers/image/plugin/autotests/test_slidefiltermodel.cpp
M  +12   -9    wallpapers/image/plugin/autotests/test_slidemodel.cpp
A  +-    --    wallpapers/image/plugin/autotests/testdata/default/# BUG454692 file name with hash char.png
M  +4    -3    wallpapers/image/plugin/autotests/tst_imagebackend.qml

https://invent.kde.org/plasma/plasma-workspace/commit/79e55866472dcd812f8cde4830e89a4bcaf47263
Comment 6 Nate Graham 2022-06-02 19:02:29 UTC
*** Bug 440071 has been marked as a duplicate of this bug. ***
Comment 7 Reiddragon 2022-12-24 20:54:32 UTC
As of 5.26.4, I've been able to reproduce this with a backslash anywhere in the path of the image file, reopening the bug as it doesn't seem to be completely fixed

Operating System: Arch Linux
KDE Plasma Version: 5.26.4
KDE Frameworks Version: 5.101.0
Qt Version: 5.15.7
Kernel Version: 6.1.1-arch1-1 (64-bit)
Graphics Platform: Wayland
Comment 8 Fushan Wen 2022-12-25 00:48:02 UTC
(In reply to Reiddragon from comment #7)
> As of 5.26.4, I've been able to reproduce this with a backslash anywhere in
> the path of the image file, reopening the bug as it doesn't seem to be
> completely fixed
> 
> Operating System: Arch Linux
> KDE Plasma Version: 5.26.4
> KDE Frameworks Version: 5.101.0
> Qt Version: 5.15.7
> Kernel Version: 6.1.1-arch1-1 (64-bit)
> Graphics Platform: Wayland

Can reproduce but I don't understand why you have to add a backslash to your filename.
Comment 9 Bug Janitor Service 2022-12-25 02:06:12 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2460
Comment 10 Fushan Wen 2022-12-25 14:05:25 UTC
Git commit 0c7854a7b587d713f17883003f436af972bb08ff by Fushan Wen.
Committed on 25/12/2022 at 14:04.
Pushed by fusionfuture into branch 'master'.

wallpapers/image: use `QUrl::fromUserInput` to sanitize filename

fromUserInput will add file:// for local files, and sanitize some
bizzare characters in filenames.
FIXED-IN: 5.27

M  +2    -1    wallpapers/image/plugin/autotests/commontestdata.h
M  +1    -0    wallpapers/image/plugin/autotests/test_imagefinder.cpp
M  +2    -0    wallpapers/image/plugin/autotests/test_imagelistmodel.cpp
M  +4    -0    wallpapers/image/plugin/autotests/test_imageproxymodel.cpp
M  +2    -0    wallpapers/image/plugin/autotests/test_slidemodel.cpp
A  +-    --    wallpapers/image/plugin/autotests/testdata/default/\ BUG454692 file name with backslash.png
M  +6    -0    wallpapers/image/plugin/autotests/tst_imagebackend.cpp
M  +14   -0    wallpapers/image/plugin/autotests/tst_imagebackend.qml
M  +1    -1    wallpapers/image/plugin/autotests/tst_imagefrontend.cpp
M  +4    -4    wallpapers/image/plugin/imagebackend.cpp
M  +14   -23   wallpapers/image/plugin/utils/mediaproxy.cpp
M  +0    -3    wallpapers/image/plugin/utils/mediaproxy.h

https://invent.kde.org/plasma/plasma-workspace/commit/0c7854a7b587d713f17883003f436af972bb08ff
Comment 11 Fushan Wen 2023-01-23 00:50:43 UTC
*** Bug 464658 has been marked as a duplicate of this bug. ***