From a1fdb95d8c76f9ab19d4dfd1c72103f34147cd35 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Mon, 20 Dec 2021 11:38:52 +0100 Subject: [PATCH] [webshortcutsrunner] Fix private browsing with some Firefoxes Because we can't have nice things the private browsing action in Firefox sometimes has a %u placeholder for the URL and sometimes doesn't. The current code only accounts for the case without placeholder, which is also what Chrome does. Replace the placeholder if found, otherwise append the URL --- runners/webshortcuts/webshortcutrunner.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/runners/webshortcuts/webshortcutrunner.cpp b/runners/webshortcuts/webshortcutrunner.cpp index 5c3d9baf5..758c02eeb 100644 --- a/runners/webshortcuts/webshortcutrunner.cpp +++ b/runners/webshortcuts/webshortcutrunner.cpp @@ -154,7 +154,19 @@ void WebshortcutRunner::run(const Plasma::RunnerContext &context, const Plasma:: if (!location.isEmpty()) { if (match.selectedAction()) { - const auto command = m_privateAction.exec() + QLatin1Char(' ') + KShell::quoteArg(location.toString()); + QString command; + + // Chrome's exec line does not have a URL placeholder + // Firefox's does, but only sometimes, depending on the distro + // Replace placeholders if found, otherwise append at the end + if (m_privateAction.exec().contains("%u")) { + command = m_privateAction.exec().replace("%u", KShell::quoteArg(location.toString())); + } else if (m_privateAction.exec().contains("%U")) { + command = m_privateAction.exec().replace("%U", KShell::quoteArg(location.toString())); + } else { + command = m_privateAction.exec() + QLatin1Char(' ') + KShell::quoteArg(location.toString()); + } + auto *job = new KIO::CommandLauncherJob(command); job->start(); } else {