Bug 512562 - QSql of apostrophes in .desktop filenames results in huge logspam
Summary: QSql of apostrophes in .desktop filenames results in huge logspam
Status: RESOLVED FIXED
Alias: None
Product: plasma-activities
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Manjaro Linux
: HI normal
Target Milestone: ---
Assignee: Ivan Čukić
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-24 15:51 UTC by Olivia Laari
Modified: 2025-12-09 14:13 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.5.5
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivia Laari 2025-11-24 15:51:03 UTC
SUMMARY
Searching for .desktop shortcuts whose filename include an apostrophe from the application launcher spams gigantic QSqlErrors blocks in journal.

STEPS TO REPRODUCE
1. run `touch ~/.local/share/applications/Tes\'t.desktop`
2. update cache `kbuildsycoca6 --noincremental`
3. open application launcher and try to look up for said Tes't
4. get gigantic blocks of QSqlErrors about syntax errors in journal

OBSERVED RESULT

plasmashell[1604]: [Error at ResultSetPrivate::initQuery]:  QSqlError("1", "Unable to execute statement", "near \"s\": syntax error") in query:
plasmashell[1604]:
                               SELECT
                                   from_table.targettedResource as resource
                                 , SUM(from_table.cachedScore)  as score
                                 , MIN(from_table.firstUpdate)  as firstUpdate
                                 , MAX(from_table.lastUpdate)   as lastUpdate
                                 , from_table.usedActivity      as activity
                                 , from_table.initiatingAgent   as agent
                                 , COALESCE(ri.title, from_table.targettedResource) as title
                                 , ri.mimetype as mimetype
                                 , 1 as linkStatus

                               FROM
                                   ResourceScoreCache from_table
                               LEFT JOIN
                                   ResourceInfo ri
                                   ON from_table.targettedResource = ri.targettedResource



                               WHERE
                                   (agent = 'The Devil\'s Calculator')
                                   AND (activity = '87a55533-4845-4b3e-937b-87df1fbceec5')
                                   AND (resource LIKE '/%' ESCAPE '\' OR resource LIKE 'smb:%' ESCAPE '\' OR resource LIKE 'fish:%' ESCAPE '\' OR resource LIKE 'sftp:%' ESCAPE '\' OR resource LIKE 'ftp:%' ESCAPE '\')
                                   AND (1)
                                   AND (1)
                                   AND (1)

                               GROUP BY resource, title

                               ORDER BY linkStatus DESC, lastUpdate DESC, resource ASC
                                LIMIT 50

plasmashell[1604]: Failed to resolve executable from service. Error: "No Exec field in /home/saukko/.local/share/applications/Tes't.desktop"
plasmashell[1604]: [Error at ResultSetPrivate::initQuery]:  QSqlError("1", "Unable to execute statement", "near \"t\": syntax error") in query:
plasmashell[1604]:
                               SELECT
                                   from_table.targettedResource as resource
                                 , SUM(from_table.cachedScore)  as score
                                 , MIN(from_table.firstUpdate)  as firstUpdate
                                 , MAX(from_table.lastUpdate)   as lastUpdate
                                 , from_table.usedActivity      as activity
                                 , from_table.initiatingAgent   as agent
                                 , COALESCE(ri.title, from_table.targettedResource) as title
                                 , ri.mimetype as mimetype
                                 , 1 as linkStatus

                               FROM
                                   ResourceScoreCache from_table
                               LEFT JOIN
                                   ResourceInfo ri
                                   ON from_table.targettedResource = ri.targettedResource



                               WHERE
                                   (agent = 'Tes\'t')
                                   AND (activity = '87a55533-4845-4b3e-937b-87df1fbceec5')
                                   AND (resource LIKE '/%' ESCAPE '\' OR resource LIKE 'smb:%' ESCAPE '\' OR resource LIKE 'fish:%' ESCAPE '\' OR resource LIKE 'sftp:%' ESCAPE '\' OR resource LIKE 'ftp:%' ESCAPE '\')
                                   AND (1)
                                   AND (1)
                                   AND (1)

                               GROUP BY resource, title

                               ORDER BY linkStatus DESC, lastUpdate DESC, resource ASC
                                LIMIT 50


EXPECTED RESULT
No logspam

SOFTWARE/OS VERSIONS
kinfo:
Operating System: Manjaro Linux
KDE Plasma Version: 6.5.3
KDE Frameworks Version: 6.20.0
Qt Version: 6.10.0
Kernel Version: 6.18.0-rc6-2-MANJARO (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5800X3D 8-Core Processor
Memory: 128 GiB of RAM (125.4 GiB usable)
Graphics Processor: AMD Radeon RX 7900 XTX

ADDITIONAL INFORMATION
1. I wasn't able to locate and look at plasmashell's sql impl but i assume this is possibly the exact issue https://stackoverflow.com/a/17280686

2. A non-dummy example .desktop file:
$ The Devil's Calculator.desktop
[Desktop Entry]
Name=The Devil's Calculator
Comment=Play this game on Steam
Exec=steam steam://rungameid/1014280
Icon=steam_icon_1014280
Terminal=false
Type=Application
Categories=Game;
Comment 1 David Redondo 2025-12-09 09:47:51 UTC
This is an illegal name for a desktop file

 For applications, the part of the name of the desktop file before the .desktop extension should be a valid D-Bus well-known name. This means that it is a sequence of non-empty elements separated by dots (U+002E FULL STOP), none of which starts with a digit, and each of which contains only characters from the set [A-Za-z0-9-_]: ASCII letters, digits, dash (U+002D HYPHEN-MINUS) and underscore (U+005F LOW LINE).
Comment 2 Bug Janitor Service 2025-12-09 11:29:41 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-activities-stats/-/merge_requests/69
Comment 3 David Redondo 2025-12-09 13:28:49 UTC
Git commit b59b98ba30ba6504c671824f0c29b52cc6868613 by David Redondo.
Committed on 09/12/2025 at 13:09.
Pushed by davidre into branch 'master'.

Properly escape single quotes in strings

Unfortunately the ESCAPE clause can only used with a LIKE Operator
and only escapes wildcard characters. Single quotes can be escaped
using double single quotes.
FIXED-IN:6.5.5

M  +6    -3    src/common/database/Database.h
M  +2    -5    src/resultset.cpp

https://invent.kde.org/plasma/plasma-activities-stats/-/commit/b59b98ba30ba6504c671824f0c29b52cc6868613
Comment 4 David Redondo 2025-12-09 14:13:38 UTC
Git commit 187b325a97744e478be8f589fc80765390793a78 by David Redondo.
Committed on 09/12/2025 at 14:04.
Pushed by davidre into branch 'Plasma/6.5'.

Properly escape single quotes in strings

Unfortunately the ESCAPE clause can only used with a LIKE Operator
and only escapes wildcard characters. Single quotes can be escaped
using double single quotes.
FIXED-IN:6.5.5


(cherry picked from commit b59b98ba30ba6504c671824f0c29b52cc6868613)

Co-authored-by: David Redondo <kde@david-redondo.de>

M  +6    -3    src/common/database/Database.h
M  +2    -5    src/resultset.cpp

https://invent.kde.org/plasma/plasma-activities-stats/-/commit/187b325a97744e478be8f589fc80765390793a78