From 53935fecf5ba365d359e30abac497e277ea40f9e Mon Sep 17 00:00:00 2001 From: relikd Date: Wed, 28 Feb 2024 01:43:23 +0100 Subject: [PATCH] fix: fallback to unicode btoa --- script.js | 15 +++++++++++++-- tools/plist_server.py | 1 - 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/script.js b/script.js index e7391f95..17d7d0f0 100644 --- a/script.js +++ b/script.js @@ -309,6 +309,10 @@ function urlWithSlash(url) { return url.toString().slice(-1) === '/' ? url : (url + '/'); } +function utoa(data) { + return btoa(unescape(encodeURIComponent(data))); + } + function installIpa(idx) { if (!plistGeneratorUrl) { document.getElementById('overlay').hidden = false; @@ -316,16 +320,23 @@ function installIpa(idx) { } const thisServerUrl = location.href.replace(location.hash, ''); const entry = entriesToDict(DB[idx]); - var b64 = btoa(JSON.stringify({ + const json = JSON.stringify({ u: validUrl(entry.ipa_url), n: entry.title, b: entry.bundleId, v: entry.version.split(' ')[0], i: urlWithSlash(thisServerUrl) + entry.img_url, - }, null, 0)); + }, null, 0) + var b64 = ''; + try { + b64 = btoa(json); + } catch (error) { + b64 = utoa(json); + } while (b64.slice(-1) === '=') { b64 = b64.slice(0, -1); } + // window.open(plistGeneratorUrl + '?d=' + b64); const plistUrl = plistGeneratorUrl + '%3Fd%3D' + b64; // url encoded "?d=" window.open('itms-services://?action=download-manifest&url=' + plistUrl); } diff --git a/tools/plist_server.py b/tools/plist_server.py index 506f74a7..d153223a 100755 --- a/tools/plist_server.py +++ b/tools/plist_server.py @@ -27,7 +27,6 @@ class PlistServer(BaseHTTPRequestHandler): def do_GET(self): try: b64 = self.path.split('?d=')[-1] + '==' - print(b64decode(b64)) data = json.loads(b64decode(b64)) # type: dict rv = generatePlist(data) except Exception as e: