From 36b954ef07a67041077544b1b2e3c31843479245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sz=C3=B3kov=C3=A1cs=20R=C3=B3bert?= Date: Thu, 4 Nov 2010 03:14:07 -0400 Subject: [PATCH] Bug 513648: strip embedded newlines and whitespace when middleclick-pasting URLs, r+a=gavin --HG-- extra : rebase_source : 7c1ef8fabde83c284c123d758484abd22dd4eb33 --- browser/base/content/browser.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index c777fc87248..9f62db0ac05 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -5167,7 +5167,15 @@ function handleLinkClick(event, href, linkNode) { } function middleMousePaste(event) { - var url = getShortcutOrURI(readFromClipboard()); + let clipboard = readFromClipboard(); + if (!clipboard) + return; + + // Strip embedded newlines and surrounding whitespace, to match the URL + // bar's behavior (stripsurroundingwhitespace) + clipboard.replace(/\s*\n\s*/g, ""); + + let url = getShortcutOrURI(clipboard); try { makeURI(url); } catch (ex) {