From 8ca1e3ba70ef71383396fbd4074e789f76629288 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 28 Jul 2022 01:59:29 +0300 Subject: [PATCH] fixup! foolproof escaping --- background/uso-api.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/background/uso-api.js b/background/uso-api.js index 41993e00..d21e1107 100644 --- a/background/uso-api.js +++ b/background/uso-api.js @@ -9,21 +9,20 @@ const usoApi = { * https://github.com/33kk/uso-archive/blob/flomaster/lib/converters.js */ async toUsercss(data, {metaOnly = true} = {}) { - const {user, style_settings: ss = []} = data; const badKeys = {}; const newKeys = []; const descr = JSON.stringify(data.description.trim()); - const vars = ss.map(makeVar).join('').replace(/\*\//g, '*\\/'); + const vars = (data.style_settings || []).map(makeVar).join(''); const sourceCode = `\ /* ==UserStyle== @name ${data.name} @namespace USO Archive @version ${data.updated.replace(/-/g, '').replace(/[T:]/g, '.').slice(0, 14)} @description ${descr.includes('\\') ? descr : descr.slice(1, -1)} -@author ${user && user.name || '?'} +@author ${(data.user || {}).name || '?'} @license ${makeLicense(data.license)}${vars ? '\n@preprocessor uso' + vars : ''} -==/UserStyle== */ -${newKeys[0] ? useNewKeys(data.css) : data.css}`; +`.replace(/\*\//g, '*\\/') + + `==/UserStyle== */\n${newKeys[0] ? useNewKeys(data.css) : data.css}`; const res = await usercssMan.build({sourceCode, metaOnly}); return Object.assign(res, {badKeys, newKeys});