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. :/ )
This commit is contained in:
dumbmoron 2023-11-23 14:44:25 +00:00
parent 60743cdcdf
commit 190a0131d4
No known key found for this signature in database
GPG key ID: C59997C76C6A8E5F
2 changed files with 2 additions and 2 deletions

View file

@ -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];

View file

@ -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) {