1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 10:22:30 +01:00
This commit is contained in:
gorhill 2015-12-14 00:54:41 -05:00
parent 33291c4dca
commit af4dba5158
2 changed files with 5 additions and 3 deletions

View File

@ -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':

View File

@ -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 ) {