summaryrefslogtreecommitdiffstats
path: root/browser/components/messagepreview
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
commitda4c7e7ed675c3bf405668739c3012d140856109 (patch)
treecdd868dba063fecba609a1d819de271f0d51b23e /browser/components/messagepreview
parentAdding upstream version 125.0.3. (diff)
downloadfirefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz
firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/messagepreview')
-rw-r--r--browser/components/messagepreview/messagepreview.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/browser/components/messagepreview/messagepreview.js b/browser/components/messagepreview/messagepreview.js
index 48e5fb1ff5..bec0a2d8eb 100644
--- a/browser/components/messagepreview/messagepreview.js
+++ b/browser/components/messagepreview/messagepreview.js
@@ -6,13 +6,25 @@
"use strict";
+// decode a 16-bit string in which only one byte of each
+// 16-bit unit is occupied, to UTF-8. This is necessary to
+// comply with `btoa` API constraints.
+function fromBinary(encoded) {
+ const binary = atob(decodeURIComponent(encoded));
+ const bytes = new Uint8Array(binary.length);
+ for (let i = 0; i < bytes.length; i++) {
+ bytes[i] = binary.charCodeAt(i);
+ }
+ return String.fromCharCode(...new Uint16Array(bytes.buffer));
+}
+
function decodeMessageFromUrl() {
const url = new URL(document.location.href);
if (url.searchParams.has("json")) {
const encodedMessage = url.searchParams.get("json");
- return atob(encodedMessage);
+ return fromBinary(encodedMessage);
}
return null;
}