Bug 467369

Summary: When creating a link to an application from the desktop context menu, selecting the program path from the browse dialogue doesn't work with spaces
Product: [Frameworks and Libraries] frameworks-kio Reporter: squaduck
Component: Properties dialogAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: bharadwaj.raju777, kde, kdelibs-bugs, liubomirwm, nate, nicolas.fella
Priority: NOR    
Version: 5.104.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In: 5.106
Attachments: Short video of the bug
actual webm video

Description squaduck 2023-03-14 22:15:54 UTC
Created attachment 157288 [details]
Short video of the bug

SUMMARY
When creating a link to an application from the desktop context menu, selecting the program path from the browse dialogue will produce a mess of escaped quotes in the .desktop file

STEPS TO REPRODUCE
1. Right click on the desktop and navigate to Create New -> Link to Application 
2. Click over to the "Application" tab
3. Click the "Browse..." button to open the browse dialogue
4. Navigate to an application with a space character in the path and open it
5. The "Program:" field will now be populated with something like '/path/to/the application/application'
6. Click OK

OBSERVED RESULT
The created .desktop file will now have a line like Exec=''\\''/path/to/the application/application'\\'''

EXPECTED RESULT
The line being Exec='/path/to/the application/application'

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: OpenSUSE Tumbleweed 20230313
KDE Plasma Version: 5.27.2
KDE Frameworks Version: 5.104.0
Qt Version: 5.15.8
Comment 1 squaduck 2023-03-14 22:26:33 UTC
Created attachment 157289 [details]
actual webm video
Comment 2 Nate Graham 2023-03-15 17:38:49 UTC
Can reproduce the issue.
Comment 3 Bug Janitor Service 2023-04-24 04:09:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1264
Comment 4 Bharadwaj Raju 2023-04-25 18:11:14 UTC
Git commit 37481256967b1f0f24e6da8530eacb8bbec758bf by Bharadwaj Raju.
Committed on 25/04/2023 at 18:11.
Pushed by bharadwaj-raju into branch 'master'.

KPropertiesDialog: Don't quote the path unnecessarily

We don't need to KShell::quoteArg the executable path, since we use
KShell::joinArgs later which takes care of proper quoting.

cc @davidedmundson 

M  +1    -2    src/widgets/kpropertiesdialog.cpp

https://invent.kde.org/frameworks/kio/commit/37481256967b1f0f24e6da8530eacb8bbec758bf
Comment 5 Bharadwaj Raju 2023-04-25 18:12:24 UTC
Git commit bf3c43369b5626740339a62733715ec27104db7e by Bharadwaj Raju.
Committed on 25/04/2023 at 18:12.
Pushed by bharadwaj-raju into branch 'kf5'.

KPropertiesDialog: Don't quote the path unnecessarily

We don't need to KShell::quoteArg the executable path, since we use
KShell::joinArgs later which takes care of proper quoting.

cc @davidedmundson 


(cherry picked from commit 37481256967b1f0f24e6da8530eacb8bbec758bf)

M  +1    -2    src/widgets/kpropertiesdialog.cpp

https://invent.kde.org/frameworks/kio/commit/bf3c43369b5626740339a62733715ec27104db7e
Comment 6 Nate Graham 2023-05-22 19:53:30 UTC
*** Bug 470038 has been marked as a duplicate of this bug. ***