From 12ff2f06ad611371200ae5625319b497a7cbfb13 Mon Sep 17 00:00:00 2001 From: Thomas Groman Date: Fri, 8 May 2020 01:51:36 -0700 Subject: Add pref to allow copying unescaped URL from the URL bar --- webbrowser/app/profile/webbrowser.js | 7 ++++--- webbrowser/base/content/urlbarBindings.xml | 20 +++++++++----------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/webbrowser/app/profile/webbrowser.js b/webbrowser/app/profile/webbrowser.js index 3aa8426..567a7b5 100644 --- a/webbrowser/app/profile/webbrowser.js +++ b/webbrowser/app/profile/webbrowser.js @@ -1,7 +1,4 @@ # -*- Mode: JavaScript; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. // XXX Toolkit-specific preferences should be moved into toolkit.js @@ -321,6 +318,10 @@ pref("browser.identity.display_punycode", 1); // Address bar RSS icon control, show by default pref("browser.urlbar.rss", true); +// If changed to true, copying the entire URL from the location bar will put +// the human readable (percent-decoded) URL on the clipboard. +pref("browser.urlbar.decodeURLsOnCopy", false); + pref("browser.altClickSave", true); // Enable logging downloads operations to the Error Console. diff --git a/webbrowser/base/content/urlbarBindings.xml b/webbrowser/base/content/urlbarBindings.xml index 31d6aa5..7da925f 100644 --- a/webbrowser/base/content/urlbarBindings.xml +++ b/webbrowser/base/content/urlbarBindings.xml @@ -520,19 +520,17 @@ uri = uriFixup.createExposableURI(uri); } catch (ex) {} - // If the entire URL is selected, just use the actual loaded URI. - if (inputVal == selectedVal) { - // ... but only if isn't a javascript: or data: URI, since those - // are hard to read when encoded - if (!uri.schemeIs("javascript") && !uri.schemeIs("data")) { - selectedVal = uri.spec; - } - - return selectedVal; + // If the entire URL is selected, just use the actual loaded URI, + // unless we want a decoded URI, or it's a data: or javascript: URI, + // since those are hard to read when encoded. + if (inputVal == selectedVal && + !uri.schemeIs("javascript") && !uri.schemeIs("data") && + !Services.prefs.getBoolPref("browser.urlbar.decodeURLsOnCopy")) { + return uri.spec; } - // Just the beginning of the URL is selected, check for a trimmed - // value + // Just the beginning of the URL is selected, or we want a decoded + // url. First check for a trimmed value. let spec = uri.spec; let trimmedSpec = this.trimValue(spec); if (spec != trimmedSpec) { -- cgit v1.2.3