1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 21:00:23 +01:00

Fetch errors in URL regular expressions creation #2

Fixes #602
This commit is contained in:
kkapsner 2022-04-24 20:50:06 +02:00
parent 4443d0a117
commit cfb09075eb
2 changed files with 12 additions and 2 deletions

View File

@ -15,6 +15,7 @@
} }
const settings = require("./settings"); const settings = require("./settings");
const logging = require("./logging");
function getDomainRegExpList(domainList){ function getDomainRegExpList(domainList){
@ -33,8 +34,17 @@
regExp = new RegExp("(?:^|\\.)" + entry.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "\\.?$", "i"); regExp = new RegExp("(?:^|\\.)" + entry.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "\\.?$", "i");
} }
else { else {
try {
regExp = new RegExp(entry, "i"); regExp = new RegExp(entry, "i");
} }
catch (error){
logging.error("Error in regular expression", entry, error);
regExp = new RegExp(
"(?:^|\\.)" + entry.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "\\.?$",
"i"
);
}
}
return { return {
value: entry, value: entry,
match: function(url){ match: function(url){

View File

@ -6,7 +6,7 @@ Version 1.9:
- -
fixes: fixes:
- - errors in URL regular expressions broke CB
known issues: known issues:
- if a data URL is blocked the page action button does not appear - if a data URL is blocked the page action button does not appear