8ad69215.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 8ad6921524c92a0cf1b58336b3ce29e159e83b7d Mon Sep 17 00:00:00 2001
  2. From: David Edmundson <kde@davidedmundson.co.uk>
  3. Date: Wed, 14 Jul 2021 17:06:59 +0100
  4. Subject: [PATCH] Fix selecting binaries from component chooser KCM
  5. In the kcmshell for a component chooser we use the open with dialog to
  6. select services for various scheme handlers.
  7. If you select a binary instead of a .desktop file a temporary .desktop
  8. file is created in ~/.local/share/applications
  9. This is in the format
  10. Exec=someBinary
  11. MimeType=x-scheme-handler/http
  12. When we then use this application for launching kio-kf6::DesktopExecParser
  13. then (sort of correctly) determines that that the chosen service cannot
  14. handle the http scheme because even though it is a scheme handler it
  15. does not have a "%u" in the exec line.
  16. This leads to us potentially loading websites via kio-kf6client or kio-kf6-fuse.
  17. Testing done:
  18. - kcmshell5 component chooser
  19. - web browser -> other -> type "/usr/bin/firefox"
  20. - kde-open5 http://kde.org
  21. - Previously this gave a local URL, now it is correct
  22. ---
  23. src/widgets/kopenwithdialog.cpp | 8 ++++++++
  24. 1 file changed, 8 insertions(+)
  25. diff --git a/src/widgets/kopenwithdialog.cpp b/src/widgets/kopenwithdialog.cpp
  26. index 1831878ca..31295044d 100644
  27. --- a/src/widgets/kopenwithdialog.cpp
  28. +++ b/src/widgets/kopenwithdialog.cpp
  29. @@ -1088,6 +1088,14 @@ bool KOpenWithDialogPrivate::checkAccept()
  30. kconfig-kf6Group cg = desktopFile.desktopGroup();
  31. cg.writeEntry("Type", "Application");
  32. cg.writeEntry("Name", initialServiceName);
  33. +
  34. + // if we select a binary for a scheme handler, then it's safe to assume it can handle URLs
  35. + if (qMimeType.startsWith(QLatin1String("x-scheme-handler/"))) {
  36. + if (!typedExec.contains(QLatin1String("%u"), Qt::CaseInsensitive) && !typedExec.contains(QLatin1String("%f"), Qt::CaseInsensitive)) {
  37. + fullExec += QStringLiteral(" %u");
  38. + }
  39. + }
  40. +
  41. cg.writeEntry("Exec", fullExec);
  42. cg.writeEntry("NoDisplay", true); // don't make it appear in the K menu
  43. if (terminal->isChecked()) {
  44. --
  45. GitLab