Bug 1495327 - Specially forged Text Pasted into the Address Bar Causes Firefox to Freeze. r=adw
authorMarco Bonardo <mbonardo@mozilla.com>
Wed, 10 Oct 2018 22:50:36 +0000
changeset 440705 8da12a6048fba4e59a860386b075f4d9070f79bf
parent 440704 8958a60dd82423a4689837029be94e6d032f6b8c
child 440706 80b93ae22c27962c405c52328f53c49870bf4b9f
push id70764
push usermak77@bonardo.net
push dateThu, 11 Oct 2018 10:05:24 +0000
treeherderautoland@8da12a6048fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1495327
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1495327 - Specially forged Text Pasted into the Address Bar Causes Firefox to Freeze. r=adw Differential Revision: https://phabricator.services.mozilla.com/D8239
toolkit/components/places/UnifiedComplete.js
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -503,17 +503,19 @@ function makeKeyForURL(match) {
 
 /**
  * Returns whether the passed in string looks like a url.
  */
 function looksLikeUrl(str, ignoreAlphanumericHosts = false) {
   // Single word including special chars.
   return !REGEXP_SPACES.test(str) &&
          (["/", "@", ":", "["].some(c => str.includes(c)) ||
-          (ignoreAlphanumericHosts ? /(.*\..*){3,}/.test(str) : str.includes(".")));
+          (ignoreAlphanumericHosts ?
+            /^([\[\]A-Z0-9.:-]+[\.:]){3,}[\[\]A-Z0-9.:-]+$/i.test(str) :
+            str.includes(".")));
 }
 
 /**
  * Returns whether the passed in string looks like an origin.
  */
 function looksLikeOrigin(str) {
   // Single word not including path delimiters.
   return REGEXP_ORIGIN.test(str);