From 190a0131d4cbec2e867c2f29f24a889d9080356e Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Thu, 23 Nov 2023 14:44:25 +0000 Subject: [PATCH] api: url-encode UTF-8 characters in url this encode-decode construct is ugly, but necessary to retain backwards compatibility for weirdos that encode the URL when passing it in via json ( like the frontend, for example. :/ ) --- src/modules/api.js | 2 +- src/modules/sub/utils.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/api.js b/src/modules/api.js index 92fa5374..62e9a7c6 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -10,7 +10,7 @@ import hostOverrides from "./processing/hostOverrides.js"; export async function getJSON(originalURL, lang, obj) { try { - let patternMatch, url = decodeURIComponent(originalURL), + let patternMatch, url = encodeURI(decodeURIComponent(originalURL)), hostname = new URL(url).hostname.split('.'), host = hostname[hostname.length - 2]; diff --git a/src/modules/sub/utils.js b/src/modules/sub/utils.js index 41ee07db..cfb56aa8 100644 --- a/src/modules/sub/utils.js +++ b/src/modules/sub/utils.js @@ -9,7 +9,7 @@ const apiVar = { }, booleanOnly: ["isAudioOnly", "isNoTTWatermark", "isTTFullAudio", "isAudioMuted", "dubLang", "vimeoDash", "disableMetadata"] } -const forbiddenChars = ['}', '{', '(', ')', '\\', '%', '>', '<', '^', '*', '!', '~', ';', ':', ',', '`', '[', ']', '#', '$', '"', "'", "@", '==']; +const forbiddenChars = ['}', '{', '(', ')', '\\', '>', '<', '^', '*', '!', '~', ';', ':', ',', '`', '[', ']', '#', '$', '"', "'", "@", '==']; const forbiddenCharsString = ['}', '{', '%', '>', '<', '^', ';', '`', '$', '"', "@", '=']; export function apiJSON(type, obj) {