mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-01 16:33:06 +01:00
Fix parsing of trailing resource
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1419
This commit is contained in:
parent
1d2907890b
commit
d910111d4a
@ -349,12 +349,14 @@ RedirectEngine.prototype.resourceContentFromName = function(name, mime) {
|
|||||||
// Consider 'none' a reserved keyword, to be used to disable redirection.
|
// Consider 'none' a reserved keyword, to be used to disable redirection.
|
||||||
|
|
||||||
RedirectEngine.prototype.resourcesFromString = function(text) {
|
RedirectEngine.prototype.resourcesFromString = function(text) {
|
||||||
const lineIter = new µBlock.LineIterator(removeTopCommentBlock(text));
|
const lineIter = new µBlock.LineIterator(
|
||||||
|
removeTopCommentBlock(text) + '\n\n'
|
||||||
|
);
|
||||||
const reNonEmptyLine = /\S/;
|
const reNonEmptyLine = /\S/;
|
||||||
let fields, encoded, details;
|
let fields, encoded, details;
|
||||||
|
|
||||||
while ( lineIter.eot() === false ) {
|
while ( lineIter.eot() === false ) {
|
||||||
let line = lineIter.next();
|
const line = lineIter.next();
|
||||||
if ( line.startsWith('#') ) { continue; }
|
if ( line.startsWith('#') ) { continue; }
|
||||||
if ( line.startsWith('// ') ) { continue; }
|
if ( line.startsWith('// ') ) { continue; }
|
||||||
|
|
||||||
@ -396,18 +398,16 @@ RedirectEngine.prototype.resourcesFromString = function(text) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No more data, add the resource.
|
||||||
const name = this.aliases.get(fields[0]) || fields[0];
|
const name = this.aliases.get(fields[0]) || fields[0];
|
||||||
const mime = fields[1];
|
const mime = fields[1];
|
||||||
const content = µBlock.orphanizeString(
|
const content = µBlock.orphanizeString(
|
||||||
fields.slice(2).join(encoded ? '' : '\n')
|
fields.slice(2).join(encoded ? '' : '\n')
|
||||||
);
|
);
|
||||||
|
|
||||||
// No more data, add the resource.
|
|
||||||
this.resources.set(
|
this.resources.set(
|
||||||
name,
|
name,
|
||||||
RedirectEntry.fromContent(mime, content)
|
RedirectEntry.fromContent(mime, content)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( Array.isArray(details) ) {
|
if ( Array.isArray(details) ) {
|
||||||
for ( const { prop, value } of details ) {
|
for ( const { prop, value } of details ) {
|
||||||
if ( prop !== 'alias' ) { continue; }
|
if ( prop !== 'alias' ) { continue; }
|
||||||
@ -419,22 +419,6 @@ RedirectEngine.prototype.resourcesFromString = function(text) {
|
|||||||
details = undefined;
|
details = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process pending resource data.
|
|
||||||
if ( fields !== undefined ) {
|
|
||||||
const name = fields[0];
|
|
||||||
const mime = fields[1];
|
|
||||||
const content = µBlock.orphanizeString(
|
|
||||||
fields.slice(2).join(encoded ? '' : '\n')
|
|
||||||
);
|
|
||||||
this.resources.set(
|
|
||||||
name,
|
|
||||||
RedirectEntry.fromContent(mime, content)
|
|
||||||
);
|
|
||||||
if ( details instanceof Object && details.alias ) {
|
|
||||||
this.aliases.set(details.alias, name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.modifyTime = Date.now();
|
this.modifyTime = Date.now();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user