From fc4fccd8e33822dbba5b2d1d712f2fd097389433 Mon Sep 17 00:00:00 2001 From: Hugo Xu Date: Fri, 6 Apr 2018 13:59:01 -0600 Subject: [PATCH] Accept `# Title:` and `# Expires:`; optimize RegExp (#3679) * Accept `# Title:` and `# Expires`; optimize RegExp * Prevent confusion with network filter --- src/js/storage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/storage.js b/src/js/storage.js index 312dd7bb6..5a5c7b5d7 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -733,7 +733,7 @@ // https://github.com/gorhill/uBlock/issues/313 // Always try to fetch the name if this is an external filter list. if ( listEntry.title === '' || listEntry.group === 'custom' ) { - matches = head.match(/(?:^|\n)!\s*Title:([^\n]+)/i); + matches = head.match(/(?:^|\n)(?:!|# )\s*Title:([^\n]+)/i); if ( matches !== null ) { // https://bugs.chromium.org/p/v8/issues/detail?id=2869 // JSON.stringify/JSON.parse is to work around String.slice() @@ -743,7 +743,7 @@ } } // Extract update frequency information - matches = head.match(/(?:^|\n)![\t ]*Expires:[\t ]*([\d]+)[\t ]*days?/i); + matches = head.match(/(?:^|\n)(?:!|# )[\t ]*Expires:[\t ]*(\d+)[\t ]*day/i); if ( matches !== null ) { v = Math.max(parseInt(matches[1], 10), 1); if ( v !== listEntry.updateAfter ) {