Bug 471851 - kde-open with long custom URI opens browser instead of correct application
Summary: kde-open with long custom URI opens browser instead of correct application
Status: RESOLVED INTENTIONAL
Alias: None
Product: kde-cli-tools
Classification: Plasma
Component: general (other bugs)
Version First Reported In: 5.27.9
Platform: Debian stable Linux
: NOR normal
Target Milestone: ---
Assignee: Aleix Pol
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-01 23:23 UTC by egerlach
Modified: 2023-10-31 02:29 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description egerlach 2023-07-01 23:23:32 UTC
SUMMARY
I have cb_thunderlink registered to handle the cbthunderlink:// URI scheme as described in: https://camiel.bouchier.be/en/cb_thunderlink/installation/linux. However the links don't successfully open in Thunderbird as expected. I copied the link to konsole and did some experimenting and found that:

$ kde-open cbthunderlink://MjAyMy0wNy0wMVQwMzozMzo1NS4wMDBaOyJXaXNlIiA8bm9yZXBseUB3aXNlLmN

worked as expected but

$ kde-open cbthunderlink://MjAyMy0wNy0wMVQwMzozMzo1NS4wMDBaOyJXaXNlIiA8bm9yZXBseUB3aXNlLmNv

did not.

I noticed that the entire URI is 80 characters and the portion after the "://" is 64 characters, which is suspicious.

STEPS TO REPRODUCE
1. Install cb_thunderlink as https://camiel.bouchier.be/en/cb_thunderlink/installation/linux
2. Register the uri scheme handler with "xdg-mime default cb_thunderlink_cbthunderlink.desktop x-scheme-handler/cbthunderlink"
3. Copy a cbthunderlink link from Thunderbird, or use this one: cbthunderlink://MjAyMi0xMi0wN1QwNjoxMTowNy4wMDBaOyJBbGlFeHByZXNzIiA8dHJhbnNhY3Rpb25Abm90aWNlLmFsaWV4cHJlc3MuY29tPg==
4. Run "kde-open <uri>"

OBSERVED RESULT
Link opens in default browser

EXPECTED RESULT
Link opens in Thunderbird

SOFTWARE/OS VERSIONS
Operating System: Debian GNU/Linux 12
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Kernel Version: 6.1.0-9-amd64 (64-bit)


ADDITIONAL INFORMATION
I am downloading KDE Neon testing to confirm that I can reproduce there, but I won't get to that immediately.
Comment 1 egerlach 2023-07-02 19:49:16 UTC
I just tried on KDE Neon and got the same result:

Operating System: KDE neon Testing Edition
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.108.0
Qt Version: 5.15.10
Kernel Version: 5.19.0-45-generic (64-bit)
Graphics Platform: X11
Comment 2 fanzhuyifan 2023-10-29 22:18:26 UTC
Can reproduce. For me the cutoff is between `slack://123k1j2lk3j1lk23jasdfsadkfklsadjflksjakfjsdafsakjfksjfklsdjalfg1` and `slack://123k1j2lk3j1lk23jasdfsadkfklsadjflksjakfjsdafsakjfksjfklsdjalfg`.
Comment 3 fanzhuyifan 2023-10-31 02:29:41 UTC
After some research, I am closing this as INTENTIONAL.

Short answer:
Don't add the double slashes for custom schemes.
Just use custom-scheme:xxxxx, instead of custom-scheme://xxxxxx.

Long answer:
With the double slashes, the part that comes after will be interpreted as a host.
As per specifications, the host cannot have more than 63 characters.
So QUrl::fromUserInput perceives this to be an invalid url, and tries to fix this.
The 'fixed' url becomes http://custom-scheme//xxxxxxx.

On the other hand, if the double slashes are not included, 
then what comes after becomes interpreted as the path, which does not have the
63 character limit. So QUrl::fromUserInput treats it as valid url and doesn't modify it.

References:
https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
https://bugreports.qt.io/browse/QTBUG-18280