1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-01 16:33:06 +01:00

Accept # Title: and # Expires:; optimize RegExp (#3679)

* Accept `# Title:` and `# Expires`; optimize RegExp

* Prevent confusion with network filter
This commit is contained in:
Hugo Xu 2018-04-06 13:59:01 -06:00 committed by Raymond Hill
parent 79b4706746
commit fc4fccd8e3

View File

@ -733,7 +733,7 @@
// https://github.com/gorhill/uBlock/issues/313 // https://github.com/gorhill/uBlock/issues/313
// Always try to fetch the name if this is an external filter list. // Always try to fetch the name if this is an external filter list.
if ( listEntry.title === '' || listEntry.group === 'custom' ) { 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 ) { if ( matches !== null ) {
// https://bugs.chromium.org/p/v8/issues/detail?id=2869 // https://bugs.chromium.org/p/v8/issues/detail?id=2869
// JSON.stringify/JSON.parse is to work around String.slice() // JSON.stringify/JSON.parse is to work around String.slice()
@ -743,7 +743,7 @@
} }
} }
// Extract update frequency information // 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 ) { if ( matches !== null ) {
v = Math.max(parseInt(matches[1], 10), 1); v = Math.max(parseInt(matches[1], 10), 1);
if ( v !== listEntry.updateAfter ) { if ( v !== listEntry.updateAfter ) {