https://bugs.kde.org/show_bug.cgi?id=471533

            Bug ID: 471533
           Summary: KDesktopFile should be parsing Exec= line differently
    Classification: Frameworks and Libraries
           Product: frameworks-kconfig
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: matt...@mjdsystems.ca
          Reporter: m...@ratijas.tk
                CC: kdelibs-b...@kde.org
  Target Milestone: ---

SUMMARY

After recent update[1] of scrcpy, I get these warnings when e.g. launching
systemsettings:

> kf.config.core: "KConfigIni: In file 
> /usr/share/applications/scrcpy-console.desktop, line 8: " "Invalid escape 
> sequence \"\\\"\"."
> kf.config.core: "KConfigIni: In file /usr/share/applications/scrcpy.desktop, 
> line 8: " "Invalid escape sequence \"\\\"\"."

Or with a patch[2] that improves readability:

> kf.config.core: KConfigIni: In file /usr/share/applications/scrcpy.desktop, 
> line 8: Invalid escape sequence: «\"»

scrcpy.desktop has the following Exec line:

> Exec=/bin/sh -c "\"\\$SHELL\" -i -c scrcpy"

It seems that escape sequences are fine, and it's our parser that is broken.
According to the documentation at FDO [3], Exec= line has some special rules
about escape sequences.

STEPS TO REPRODUCE
1. Parse a file that contains the line above with KConfig, KDesktopFile or
KService.

OBSERVED RESULT
Warnings, poorly escaped resulting string.

EXPECTED RESULT
Adherence to standards, no warnings.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Frameworks Version: 5.240.0 (kf6/master)
Qt Version: 6.5.1

ADDITIONAL INFORMATION

[1]:
https://github.com/Genymobile/scrcpy/commit/d2b7315ba693e11bd9b9a0421a75b7df8a31c5cc
[2]: https://invent.kde.org/frameworks/kconfig/-/merge_requests/203
[3]:
https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables

In kservice.cpp, the `init()` method fetches "Exec" entry using regular
`desktopGroup.readEntry("Exec", QString());` call, without any specialized
processing. It seems wrong. KDesktopFile has many `read$Thing` methods, but
Exec is not one of them. Looking at the added complexity of special escaping
rules, it probably should have that as well.

And before you ask, no — KIO::DesktopExecParser is NOT a solution. It takes an
instance of KService in constructor, which is already messed up by that time.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to