Bug 502280

Summary: KCoreDirLister fails to update for paths containing square brackets
Product: [Frameworks and Libraries] frameworks-kio Reporter: Jin Liu <ad.liu.jin>
Component: generalAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: normal CC: kdelibs-bugs, thiago
Priority: NOR    
Version First Reported In: git master   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Jin Liu 2025-04-01 13:32:15 UTC
SUMMARY
Qt 6.8.3 (in https://github.com/qt/qtbase/commit/5e936b60fc921e21b8153a83113886a1de333b57) introduced a breaking change in QUrl::fromLocalPath, which now escapes square brackets.

This causes KCoreDirLister to not update for paths containing square brackets, as local URLs in its cache are not escaped, but local URLs from KDirWatch are.

STEPS TO REPRODUCE
1. dolphin . &
2. touch '[test].txt'
3. note the file size in dolphin (0)
4. cat >> '[test].txt'

OBSERVED RESULT
File size doesn't update.

EXPECTED RESULT
File size should be 4.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.3.80
KDE Frameworks Version: 6.13.0
Qt Version: 6.8.3
Kernel Version: 6.12.21-1-lts (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 5600H with Radeon Graphics
Memory: 16 GiB of RAM (15.0 GiB usable)
Graphics Processor: AMD Radeon Graphics
Comment 1 Bug Janitor Service 2025-04-01 14:39:01 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1854
Comment 3 Jin Liu 2025-04-05 01:29:17 UTC
Git commit 943eae6247f602e0b27c950a50cb2ac5764a3c77 by Jin Liu.
Committed on 05/04/2025 at 01:29.
Pushed by genericity into branch 'master'.

KFileItem/KDirLister: add test for paths with square brackets

Qt 6.8.3 (in https://github.com/qt/qtbase/commit/5e936b60fc921e21b8153a83113886a1de333b57)
introduced a breaking change in QUrl::fromLocalPath, which now escapes
square brackets.

But we were using QUrl::setPath() which doesn't escape square brackets.
So our url() might be different from the same local path converted by
QUrl::fromLocalPath().

This causes KCoreDirLister to not update for paths containing square
brackets, as it escapes local URLs from KDirWatch, but not from dir
listing, resulting in mismatch.

Qt 6.8.2 and 6.9.0 doesn't contain the above change, so they are good.
The upcoming release Qt 6.8.4 and 6.9.1 should contain the fix in 
(https://codereview.qt-project.org/c/qt/qtbase/+/636882) so setPath()
would be consistent with fromLocalPath() again. No fix needed on our
side.

This MR adds tests for this bug. (will be skipped on Qt 6.8.3 / 6.9.0)

M  +27   -0    autotests/kdirlistertest.cpp
M  +1    -0    autotests/kdirlistertest.h
M  +13   -0    autotests/kfileitemtest.cpp
M  +2    -0    autotests/kfileitemtest.h

https://invent.kde.org/frameworks/kio/-/commit/943eae6247f602e0b27c950a50cb2ac5764a3c77
Comment 4 Jin Liu 2025-04-06 01:35:54 UTC
Should be fixed by https://codereview.qt-project.org/c/qt/qtbase/+/636882