Bug 1250366 - fix whitespace issues with URL highlight code, r?jaws
MozReview-Commit-ID: 1i0IiZ7EDWi
--- a/browser/base/content/test/general/browser_urlHighlight.js
+++ b/browser/base/content/test/general/browser_urlHighlight.js
@@ -55,16 +55,19 @@ function test() {
testVal("<https://sub.>mozilla.org");
testVal("<https://sub1.sub2.sub3.>mozilla.org");
testVal("<https://user:pass@sub1.sub2.sub3.>mozilla.org");
testVal("<https://user:pass@>mozilla.org");
testVal("<user:pass@sub1.sub2.sub3.>mozilla.org");
testVal("<user:pass@>mozilla.org");
+ testVal("<https://>mozilla.org< >");
+ testVal("mozilla.org< >");
+
testVal("<https://>mozilla.org</file.ext>");
testVal("<https://>mozilla.org</sub/file.ext>");
testVal("<https://>mozilla.org</sub/file.ext?foo>");
testVal("<https://>mozilla.org</sub/file.ext?foo&bar>");
testVal("<https://>mozilla.org</sub/file.ext?foo&bar#top>");
testVal("<https://>mozilla.org</sub/file.ext?foo&bar#top>");
testVal("foo.bar<?q=test>");
testVal("foo.bar<#mozilla.org>");
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -256,17 +256,17 @@ file, You can obtain one at http://mozil
// trimmedLength to ensure we don't count the length of a trimmed protocol
// when determining which parts of the URL to highlight as "preDomain".
let trimmedLength = 0;
if (uriInfo.fixedURI.scheme == "http" && !value.startsWith("http://")) {
value = "http://" + value;
trimmedLength = "http://".length;
}
- let matchedURL = value.match(/^((?:[a-z]+:\/\/)(?:[^\/#?]+@)?)(.+?)(?::\d+)?(?:[\/#?]|$)/);
+ let matchedURL = value.match(/^((?:[a-z]+:\/\/)(?:[^\/#?]+@)?)(\S+?)(?::\d+)?\s*(?:[\/#?]|$)/);
if (!matchedURL)
return;
// Strike out the "https" part if mixed active content is loaded.
if (this.getAttribute("pageproxystate") == "valid" &&
value.startsWith("https:") &&
gBrowser.securityUI.state &
Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT) {