diff --git a/backend/package.json b/backend/package.json index 9371728..e5c5b3a 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.19.94", + "version": "2.19.95", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/artifacts.js b/backend/src/restful/artifacts.js index e4626a3..f172397 100644 --- a/backend/src/restful/artifacts.js +++ b/backend/src/restful/artifacts.js @@ -112,7 +112,6 @@ function replaceArtifact(req, res) { async function getArtifact(req, res) { let { name } = req.params; - name = decodeURIComponent(name); const allArtifacts = $.read(ARTIFACTS_KEY); const artifact = findByName(allArtifacts, name); @@ -163,7 +162,6 @@ function createArtifact(req, res) { function updateArtifact(req, res) { const allArtifacts = $.read(ARTIFACTS_KEY); let oldName = req.params.name; - oldName = decodeURIComponent(oldName); const artifact = findByName(allArtifacts, oldName); if (artifact) { $.info(`正在更新远程配置:${artifact.name}`); @@ -197,7 +195,6 @@ function updateArtifact(req, res) { async function deleteArtifact(req, res) { let { name } = req.params; - name = decodeURIComponent(name); $.info(`正在删除远程配置:${name}`); const allArtifacts = $.read(ARTIFACTS_KEY); try { diff --git a/backend/src/restful/collections.js b/backend/src/restful/collections.js index 1169984..852a1a8 100644 --- a/backend/src/restful/collections.js +++ b/backend/src/restful/collections.js @@ -52,7 +52,6 @@ function createCollection(req, res) { function getCollection(req, res) { let { name } = req.params; let { raw } = req.query; - name = decodeURIComponent(name); const allCols = $.read(COLLECTIONS_KEY); const collection = findByName(allCols, name); if (collection) { @@ -84,7 +83,6 @@ function getCollection(req, res) { function updateCollection(req, res) { let { name } = req.params; - name = decodeURIComponent(name); let collection = req.body; const allCols = $.read(COLLECTIONS_KEY); const oldCol = findByName(allCols, name); @@ -137,7 +135,6 @@ function updateCollection(req, res) { function deleteCollection(req, res) { let { name } = req.params; - name = decodeURIComponent(name); $.info(`正在删除组合订阅:${name}`); let allCols = $.read(COLLECTIONS_KEY); deleteByName(allCols, name); diff --git a/backend/src/restful/download.js b/backend/src/restful/download.js index 80afacb..89e1198 100644 --- a/backend/src/restful/download.js +++ b/backend/src/restful/download.js @@ -88,8 +88,6 @@ export default function register($app) { async function downloadSubscription(req, res) { let { name, nezhaIndex } = req.params; - name = decodeURIComponent(name); - nezhaIndex = decodeURIComponent(nezhaIndex); const useMihomoExternal = req.query.target === 'SurgeMac'; @@ -140,7 +138,6 @@ async function downloadSubscription(req, res) { $.info(`传入 $options: ${JSON.stringify($options)}`); } if (url) { - url = decodeURIComponent(url); $.info(`指定远程订阅 URL: ${url}`); if (!/^https?:\/\//.test(url)) { content = url; @@ -148,32 +145,25 @@ async function downloadSubscription(req, res) { } } if (content) { - content = decodeURIComponent(content); $.info(`指定本地订阅: ${content}`); } if (proxy) { - proxy = decodeURIComponent(proxy); $.info(`指定远程订阅使用代理/策略 proxy: ${proxy}`); } if (ua) { - ua = decodeURIComponent(ua); $.info(`指定远程订阅 User-Agent: ${ua}`); } if (mergeSources) { - mergeSources = decodeURIComponent(mergeSources); $.info(`指定合并来源: ${mergeSources}`); } if (ignoreFailedRemoteSub != null && ignoreFailedRemoteSub !== '') { - ignoreFailedRemoteSub = decodeURIComponent(ignoreFailedRemoteSub); $.info(`指定忽略失败的远程订阅: ${ignoreFailedRemoteSub}`); } if (produceType) { - produceType = decodeURIComponent(produceType); $.info(`指定生产类型: ${produceType}`); } if (includeUnsupportedProxy) { - includeUnsupportedProxy = decodeURIComponent(includeUnsupportedProxy); $.info( `包含官方/商店版/未续费订阅不支持的协议: ${includeUnsupportedProxy}`, ); @@ -362,8 +352,6 @@ async function downloadSubscription(req, res) { async function downloadCollection(req, res) { let { name, nezhaIndex } = req.params; - name = decodeURIComponent(name); - nezhaIndex = decodeURIComponent(nezhaIndex); const useMihomoExternal = req.query.target === 'SurgeMac'; @@ -416,21 +404,17 @@ async function downloadCollection(req, res) { } if (proxy) { - proxy = decodeURIComponent(proxy); $.info(`指定远程订阅使用代理/策略 proxy: ${proxy}`); } if (ignoreFailedRemoteSub != null && ignoreFailedRemoteSub !== '') { - ignoreFailedRemoteSub = decodeURIComponent(ignoreFailedRemoteSub); $.info(`指定忽略失败的远程订阅: ${ignoreFailedRemoteSub}`); } if (produceType) { - produceType = decodeURIComponent(produceType); $.info(`指定生产类型: ${produceType}`); } if (includeUnsupportedProxy) { - includeUnsupportedProxy = decodeURIComponent(includeUnsupportedProxy); $.info( `包含官方/商店版/未续费订阅不支持的协议: ${includeUnsupportedProxy}`, ); diff --git a/backend/src/restful/file.js b/backend/src/restful/file.js index a51d216..286322c 100644 --- a/backend/src/restful/file.js +++ b/backend/src/restful/file.js @@ -51,7 +51,6 @@ function createFile(req, res) { async function getFile(req, res) { let { name } = req.params; - name = decodeURIComponent(name); const reqUA = req.headers['user-agent'] || req.headers['User-Agent']; $.info(`正在下载文件:${name}\n请求 User-Agent: ${reqUA}`); let { @@ -95,42 +94,33 @@ async function getFile(req, res) { $.info(`传入 $options: ${JSON.stringify($options)}`); } if (url) { - url = decodeURIComponent(url); $.info(`指定远程文件 URL: ${url}`); } if (proxy) { - proxy = decodeURIComponent(proxy); $.info(`指定远程订阅使用代理/策略 proxy: ${proxy}`); } if (ua) { - ua = decodeURIComponent(ua); $.info(`指定远程文件 User-Agent: ${ua}`); } if (subInfoUrl) { - subInfoUrl = decodeURIComponent(subInfoUrl); $.info(`指定获取流量的 subInfoUrl: ${subInfoUrl}`); } if (subInfoUserAgent) { - subInfoUserAgent = decodeURIComponent(subInfoUserAgent); $.info(`指定获取流量的 subInfoUserAgent: ${subInfoUserAgent}`); } if (content) { - content = decodeURIComponent(content); $.info(`指定本地文件: ${content}`); } if (mergeSources) { - mergeSources = decodeURIComponent(mergeSources); $.info(`指定合并来源: ${mergeSources}`); } if (ignoreFailedRemoteFile != null && ignoreFailedRemoteFile !== '') { - ignoreFailedRemoteFile = decodeURIComponent(ignoreFailedRemoteFile); $.info(`指定忽略失败的远程文件: ${ignoreFailedRemoteFile}`); } if (noCache) { $.info(`指定不使用缓存: ${noCache}`); } if (produceType) { - produceType = decodeURIComponent(produceType); $.info(`指定生产类型: ${produceType}`); } @@ -225,7 +215,6 @@ async function getFile(req, res) { function getWholeFile(req, res) { let { name } = req.params; let { raw } = req.query; - name = decodeURIComponent(name); const allFiles = $.read(FILES_KEY); const file = findByName(allFiles, name); if (file) { @@ -257,7 +246,6 @@ function getWholeFile(req, res) { function updateFile(req, res) { let { name } = req.params; - name = decodeURIComponent(name); let file = req.body; const allFiles = $.read(FILES_KEY); const oldFile = findByName(allFiles, name); @@ -299,7 +287,6 @@ function updateFile(req, res) { function deleteFile(req, res) { let { name } = req.params; - name = decodeURIComponent(name); $.info(`正在删除文件:${name}`); let allFiles = $.read(FILES_KEY); deleteByName(allFiles, name); diff --git a/backend/src/restful/module.js b/backend/src/restful/module.js index 6ef8885..c742194 100644 --- a/backend/src/restful/module.js +++ b/backend/src/restful/module.js @@ -43,7 +43,6 @@ function createModule(req, res) { function getModule(req, res) { let { name } = req.params; - name = decodeURIComponent(name); const allModules = $.read(MODULES_KEY); const module = findByName(allModules, name); if (module) { @@ -64,7 +63,6 @@ function getModule(req, res) { function updateModule(req, res) { let { name } = req.params; - name = decodeURIComponent(name); let module = req.body; const allModules = $.read(MODULES_KEY); const oldModule = findByName(allModules, name); @@ -92,7 +90,6 @@ function updateModule(req, res) { function deleteModule(req, res) { let { name } = req.params; - name = decodeURIComponent(name); $.info(`正在删除模块:${name}`); let allModules = $.read(MODULES_KEY); deleteByName(allModules, name); diff --git a/backend/src/restful/subscriptions.js b/backend/src/restful/subscriptions.js index 411021a..2f86400 100644 --- a/backend/src/restful/subscriptions.js +++ b/backend/src/restful/subscriptions.js @@ -39,10 +39,8 @@ export default function register($app) { // subscriptions API async function getFlowInfo(req, res) { let { name } = req.params; - name = decodeURIComponent(name); let { url } = req.query; if (url) { - url = decodeURIComponent(url); $.info(`指定远程订阅 URL: ${url}`); } const allSubs = $.read(SUBS_KEY); @@ -262,7 +260,6 @@ function createSubscription(req, res) { function getSubscription(req, res) { let { name } = req.params; let { raw } = req.query; - name = decodeURIComponent(name); const allSubs = $.read(SUBS_KEY); const sub = findByName(allSubs, name); if (sub) { @@ -294,7 +291,6 @@ function getSubscription(req, res) { function updateSubscription(req, res) { let { name } = req.params; - name = decodeURIComponent(name); // the original name let sub = req.body; const allSubs = $.read(SUBS_KEY); const oldSub = findByName(allSubs, name); @@ -357,7 +353,6 @@ function updateSubscription(req, res) { function deleteSubscription(req, res) { let { name } = req.params; - name = decodeURIComponent(name); $.info(`删除订阅:${name}...`); // delete from subscriptions let allSubs = $.read(SUBS_KEY); diff --git a/backend/src/restful/sync.js b/backend/src/restful/sync.js index 8cbd7fd..a09b958 100644 --- a/backend/src/restful/sync.js +++ b/backend/src/restful/sync.js @@ -792,7 +792,6 @@ async function syncAllArtifacts(_, res) { async function syncArtifact(req, res) { let { name } = req.params; - name = decodeURIComponent(name); $.info(`开始同步远程配置 ${name}...`); const allArtifacts = $.read(ARTIFACTS_KEY); const artifact = findByName(allArtifacts, name); diff --git a/backend/src/restful/token.js b/backend/src/restful/token.js index 2184533..490c03a 100644 --- a/backend/src/restful/token.js +++ b/backend/src/restful/token.js @@ -17,7 +17,6 @@ export default function register($app) { function deleteToken(req, res) { let { token } = req.params; - token = decodeURIComponent(token); $.info(`正在删除:${token}`); let allTokens = $.read(TOKENS_KEY); deleteByName(allTokens, token, 'token'); diff --git a/backend/src/vendor/express.js b/backend/src/vendor/express.js index c931d2b..ae48af7 100644 --- a/backend/src/vendor/express.js +++ b/backend/src/vendor/express.js @@ -270,7 +270,7 @@ function extractURL(url) { let hashes = url.slice(url.indexOf('?') + 1).split('&'); for (let i = 0; i < hashes.length; i++) { const hash = hashes[i].split('='); - query[hash[0]] = hash[1]; + query[hash[0]] = decodeURIComponent(hash[1]); } } return { @@ -294,7 +294,7 @@ function extractPathParams(pattern, path) { while (path[j] !== '/' && j < path.length) { val.push(path[j++]); } - params[key.join('')] = val.join(''); + params[key.join('')] = decodeURIComponent(val.join('')); } else { if (pattern[i] !== path[j]) { return null;