mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-04 01:59:38 +02: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.
|
||||
|
||||
RedirectEngine.prototype.resourcesFromString = function(text) {
|
||||
const lineIter = new µBlock.LineIterator(removeTopCommentBlock(text));
|
||||
const lineIter = new µBlock.LineIterator(
|
||||
removeTopCommentBlock(text) + '\n\n'
|
||||
);
|
||||
const reNonEmptyLine = /\S/;
|
||||
let fields, encoded, details;
|
||||
|
||||
while ( lineIter.eot() === false ) {
|
||||
let line = lineIter.next();
|
||||
const line = lineIter.next();
|
||||
if ( line.startsWith('#') ) { continue; }
|
||||
if ( line.startsWith('// ') ) { continue; }
|
||||
|
||||
@ -396,18 +398,16 @@ RedirectEngine.prototype.resourcesFromString = function(text) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// No more data, add the resource.
|
||||
const name = this.aliases.get(fields[0]) || fields[0];
|
||||
const mime = fields[1];
|
||||
const content = µBlock.orphanizeString(
|
||||
fields.slice(2).join(encoded ? '' : '\n')
|
||||
);
|
||||
|
||||
// No more data, add the resource.
|
||||
this.resources.set(
|
||||
name,
|
||||
RedirectEntry.fromContent(mime, content)
|
||||
);
|
||||
|
||||
if ( Array.isArray(details) ) {
|
||||
for ( const { prop, value } of details ) {
|
||||
if ( prop !== 'alias' ) { continue; }
|
||||
@ -419,22 +419,6 @@ RedirectEngine.prototype.resourcesFromString = function(text) {
|
||||
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();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user