Better processing of `Expires` directive in filter list

In case of invalid `Expires` value -- i.e. `NaN` -- do
not use `1` as default value, just let uBO pick the
value according to the global default (which is `5` as
of commit time).
This commit is contained in:
Raymond Hill 2020-07-06 08:31:53 -04:00
parent dc64cfbd97
commit 18a5f41a04
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 9 additions and 6 deletions

View File

@ -760,12 +760,15 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
// Extract update frequency information
const matches = head.match(/(?:^|\n)(?:!|# )[\t ]*Expires[\t ]*:[\t ]*(\d+)[\t ]*(h)?/i);
if ( matches !== null ) {
let v = Math.max(parseInt(matches[1], 10), 1);
if ( matches[2] !== undefined ) {
v = Math.ceil(v / 24);
}
if ( v !== listEntry.updateAfter ) {
this.assets.registerAssetSource(assetKey, { updateAfter: v });
let v = parseInt(matches[1], 10);
if ( isNaN(v) === false ) {
if ( matches[2] !== undefined ) {
v = Math.ceil(v / 24);
}
v = Math.max(v, 1);
if ( v !== listEntry.updateAfter ) {
this.assets.registerAssetSource(assetKey, { updateAfter: v });
}
}
}
};