Bug 483898

Summary: Algorithm to select the default application for a mime-type is non conformant
Product: [Frameworks and Libraries] frameworks-kservice Reporter: Alessandro Astone <ales.astone>
Component: generalAssignee: KIO Bugs <kio-bugs-null>
Status: REPORTED ---    
Severity: normal CC: kde, kdelibs-bugs-null, nate, sitter
Priority: NOR Keywords: qt6
Version First Reported In: 6.0.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Alessandro Astone 2024-03-18 13:13:46 UTC
SUMMARY
The mime-apps specification at https://specifications.freedesktop.org/mime-apps-spec/latest/ar01s04.html states that all mimeapps.list files should be scanned for a valid [Default Applications] entry before falling back to [Added Associations].
In KDE instead, if you have a file at ~/.config/mimeapps.list with an invalid default application it will fall back the same file's [Added Associations] before looking at other files' [Default Applications].

The issue manifests when the distro changes the desktop file name of a browser you previously selected as default browser in systemsettings (which arguably shouldn't happen, but...)


STEPS TO REPRODUCE
1. Install a non-distro-default browser -- I'm going to use Chromium as an example
2. Backup ~/.config/mimeapps.list, if this is not a test machine
3. Create ~/.config/mimeapps.list with contents:
```
[Added Associations]
x-scheme-handler/http=bad-desktop-file.desktop;chromium-browser.desktop;
x-scheme-handler/https=bad-desktop-file.desktop;chromium-browser.desktop;
[Default Applications]
x-scheme-handler/http=bad-desktop-file.desktop;
x-scheme-handler/https=bad-desktop-file.desktop;
```
4. kbuildsycoca6
5. xdg-open http://foo

OBSERVED RESULT
https://foo opens in Chromium

EXPECTED RESULT
https://foo opens in the distro's default browser, as specified in some other XDG directory such as /usr/share/mimeapps.list

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Fedora KDE Rawhide
(available in About System)
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2

ADDITIONAL INFORMATION
GNOME's implementation seems conformant
Comment 1 Nate Graham 2024-04-10 19:34:32 UTC
Harald and David, I recall that you two are ~~unlucky~~ fortunate enough to know something about the implementation here.