Bug 501398

Summary: kde-open5 improperly parses URL-encoded spaces in obsidian:// and other custom URI schemes
Product: [Frameworks and Libraries] frameworks-kio Reporter: Mads Peter Rommedahl <kde>
Component: generalAssignee: KIO Bugs <kio-bugs-null>
Status: REPORTED ---    
Severity: normal CC: haowenshi, kdelibs-bugs-null
Priority: NOR    
Version First Reported In: 6.11.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Mads Peter Rommedahl 2025-03-12 09:04:55 UTC
SUMMARY
kde-open5 incorrectly processes obsidian:// URLs (and potentially other custom URI schemes) by stripping or incorrectly parsing %20 (space encoding) and possibly other special characters.

This results in applications failing to open the correct resource when xdg-open is used within a KDE environment.

The issue does not occur when using gio open, indicating that the bug is KDE-specific.

STEPS TO REPRODUCE
1. Ensure that obsidian:// is registered as a valid x-scheme-handler (e.g., via Flatpak: /var/lib/flatpak/exports/share/applications/md.obsidian.Obsidian.desktop).
2. run xdg-open "obsidian://open?vault=obsidian-recipes&file=Shopping%20List"

OBSERVED RESULT
Instead of "Shopping List", kde-open5 passes "Shopping" as the file parameter.
This causes Obsidian to display an error: "Note 'Shopping' not found".
Debugging shows that kde-open5 truncates everything after the first space.

EXPECTED RESULT
Obsidian opens the correct note named "Shopping List" inside the vault "obsidian-recipes".

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: openSUSE Tumbleweed
KDE Plasma Version: 6
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.2

ADDITIONAL INFORMATION
Setting XDG_CURRENT_DESKTOP=GNOME makes xdg-open work correctly by using gio open.

This works as expected (bypassing KDE utilities):
gio open "obsidian://open?vault=obsidian-recipes&file=Shopping%20List"
(Obsidian correctly opens Shopping List.)

This fails (when KDE takes over URL handling):
xdg-open "obsidian://open?vault=obsidian-recipes&file=Shopping%20List"
(Results in Obsidian searching for Shopping instead of Shopping List.)

xdg-open Debug Output (showing KDE is involved):
XDG_UTILS_DEBUG_LEVEL=2 xdg-open "obsidian://open?vault=obsidian-recipes&file=Shopping%20List"
Selected DE kde
Received callback URL obsidian://open?vault=obsidian-recipes&file=Shopping
(Note how the received callback URL has stripped everything after the first space!)

Strace output confirming kde-open5 is used:
strace -f -e execve xdg-open "obsidian://open?vault=obsidian-recipes&file=Shopping%20List"
execve("/usr/bin/xdg-open", ["xdg-open", "obsidian://open?vault=obsidian-r"...], ...)
execve("/usr/bin/kde-open5", ["kde-open5", "obsidian://open?vault=obsidian-r"...], ...)
(kde-open5 is modifying the URL before passing it forward.)

Possible Cause:
kde-open5 might be incorrectly splitting the URL on spaces instead of properly handling URL encoding.
gio open does not have this issue, indicating the problem is KDE-specific.

Impact:
Affects any application relying on URL schemes (obsidian://, potentially vscode://, tg://, etc.).
Affects all KDE users relying on xdg-open to launch URL handlers.
Forces KDE users to set XDG_CURRENT_DESKTOP=GNOME as a workaround.

Suggested Fix:
kde-open5 should respect encoded URLs (%20 should not be removed).
The full URL should be passed to applications unmodified.

Workarounds:
gio open "obsidian://open?vault=obsidian-recipes&file=Shopping%20List"
XDG_CURRENT_DESKTOP=GNOME xdg-open "obsidian://open?vault=obsidian-recipes&file=Shopping%20List"

Related Issues & Discussions:
Flatpak .desktop file for Obsidian is correctly set up (Exec=/usr/bin/flatpak run ...).
Bug only happens in KDE, not GNOME/Xfce (which use gio open).
Comment 1 ShwStone 2025-05-27 02:42:31 UTC
I also encountered similar problem. If url contained a plus character, kde-open would wrongly parse the protocol.

STEPS TO REPRODUCE
1. Ensure that vscode:// is registered as a valid x-scheme-handler
2. run xdg-open "vscode://abc+def" and also xdg-open "vscode://abcdef"

OBSERVED RESULT
When the url contained a '+', kde-open didn't launch vscode. Instead, the default browser was opened.
When the url didn't contain a '+', vscode was lauched properly.

EXPECTED RESULT
Both should launch vscode.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 6.3.5
KDE Frameworks Version: 6.14.0
Qt Version: 6.9.0

ADDITIONAL INFORMATION
Setting XDG_CURRENT_DESKTOP=GNOME makes xdg-open work correctly by using gio open.