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

Fetch errors in URL regular expressions creation

Fixes #581
This commit is contained in:
kkapsner 2022-01-30 13:11:44 +01:00
parent 4c364a9a72
commit d4fc7027eb
2 changed files with 11 additions and 2 deletions

View File

@ -174,7 +174,16 @@
);
}
else {
regExp = new RegExp(urlSetting.url, "i");
try {
regExp = new RegExp(urlSetting.url, "i");
}
catch (error){
logging.error("Error in regular expression", urlSetting.url, error);
regExp = new RegExp(
"(?:^|\\.)" + urlSetting.url.replace(/([\\+*?[^\]$(){}=!|.])/g, "\\$1") + "\\.?$",
"i"
);
}
}
const match = function(url){
if (!url){

View File

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