From af4dba51582acf0f4c44e18e4b3c9a646763263e Mon Sep 17 00:00:00 2001 From: gorhill Date: Mon, 14 Dec 2015 00:54:41 -0500 Subject: [PATCH] this fixes #1064 --- src/js/logger-ui.js | 6 ++++-- src/js/static-net-filtering.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index 693da2971..ef57a4a75 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -283,6 +283,7 @@ var filterDecompiler = (function() { return filter; }; + var reEscapeHostname = /[.[\]]/g; var reEscape = /[.+?${}()|[\]\\]/g; var reWildcards = /\*+/g; var reSeparator = /\^/g; @@ -295,7 +296,8 @@ var filterDecompiler = (function() { switch ( fid ) { case '.': - reStr = vfields[2].replace(reEscape, '\\$&'); + reStr = vfields[2].replace(reEscapeHostname, '\\$&') + + '(?:[^%.0-9a-z_-]|$)'; break; case 'a': case 'ah': @@ -316,7 +318,7 @@ var filterDecompiler = (function() { reStr = tfields[0] .replace(reEscape, '\\$&') .replace(reWildcards, '.*') - .replace(reSeparator, '[^%.0-9a-z_-]'); + .replace(reSeparator, '(?:[^%.0-9a-z_-]|$)'); break; case '//': case '//h': diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 276c589c4..3c38b593c 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -208,7 +208,7 @@ var strToRegex = function(s, anchor, flags) { // https://www.loggly.com/blog/five-invaluable-techniques-to-improve-regex-performance/ // https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions var reStr = s.replace(/[.+?${}()|[\]\\]/g, '\\$&') - .replace(/\^/g, '[^%.0-9a-z_-]') + .replace(/\^/g, '(?:[^%.0-9a-z_-]|$)') .replace(/\*/g, '[^ ]*?'); if ( anchor < 0 ) {