[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
wilder-5.24
Nicolas Fella 4 years ago
parent c58e543343
commit a1fdb95d8c
  1. 14
      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 {

Loading…
Cancel
Save