Bug 1250366 - fix whitespace issues with URL highlight code, r?jaws draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 23 Feb 2016 11:45:07 +0000
changeset 333296 209a33bcd5ec77701f692fe9cdd0f30e452a4d81
parent 333295 b65758e610753099f73f0b867ec5fa518637230b
child 514701 434063e7ce3e4324ddb532f216be71acf6b8d63c
push id11329
push usergijskruitbosch@gmail.com
push dateTue, 23 Feb 2016 11:45:30 +0000
reviewersjaws
bugs1250366
milestone47.0a1
Bug 1250366 - fix whitespace issues with URL highlight code, r?jaws MozReview-Commit-ID: 1i0IiZ7EDWi
browser/base/content/test/general/browser_urlHighlight.js
browser/base/content/urlbarBindings.xml
--- 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) {