From d6ccc9857dd29c49eabf06fc71f59c86983c4a08 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 26 Sep 2019 09:13:50 -0400 Subject: [PATCH] Fix missing newline in merging of sublists Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/736 Regression from: - https://github.com/gorhill/uBlock/commit/e27328f9319132ba7d7a27de159aa077cf80ff37 --- src/js/assets.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/js/assets.js b/src/js/assets.js index abe807bfd..caa47da14 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -236,10 +236,11 @@ api.fetchFilterList = async function(mainlistURL) { const out = []; const reInclude = /^!#include +(\S+)/gm; for ( const result of results ) { - if ( result instanceof Object === false ) { + if ( typeof result === 'string' ) { out.push(result); continue; } + if ( result instanceof Object === false ) { continue; } const content = result.content; let lastIndex = 0; for (;;) { @@ -256,10 +257,10 @@ api.fetchFilterList = async function(mainlistURL) { if ( sublistURLs.has(subURL.href) ) { continue; } sublistURLs.add(subURL.href); out.push( - content.slice(lastIndex, match.index).trim(), - `\n! >>>>>>>> ${subURL.href}\n`, + content.slice(lastIndex, match.index), + `! >>>>>>>> ${subURL.href}`, api.fetchText(subURL.href), - `! <<<<<<<< ${subURL.href}\n` + `! <<<<<<<< ${subURL.href}` ); lastIndex = reInclude.lastIndex; } @@ -282,7 +283,9 @@ api.fetchFilterList = async function(mainlistURL) { } return { url: mainlistURL, - content: allParts.join('') + content: allParts.length === 1 + ? allParts[0] + : allParts.map(s => s.trim()).filter(s => s !== '').join('\n') }; };