mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Backed out changeset 4577a311fab7 (bug 1886856) for causing newtab failures at asrouter CLOSED TREE
This commit is contained in:
parent
fbc7eca16a
commit
e5d4d5bd18
@ -15,18 +15,6 @@ const Row = props => (
|
||||
</tr>
|
||||
);
|
||||
|
||||
// Convert a UTF-8 string to a string in which only one byte of each
|
||||
// 16-bit unit is occupied. This is necessary to comply with `btoa` API constraints.
|
||||
function toBinary(string) {
|
||||
const codeUnits = new Uint16Array(string.length);
|
||||
for (let i = 0; i < codeUnits.length; i++) {
|
||||
codeUnits[i] = string.charCodeAt(i);
|
||||
}
|
||||
return btoa(
|
||||
String.fromCharCode(...Array.from(new Uint8Array(codeUnits.buffer)))
|
||||
);
|
||||
}
|
||||
|
||||
function relativeTime(timestamp) {
|
||||
if (!timestamp) {
|
||||
return "";
|
||||
@ -543,9 +531,7 @@ export class ASRouterAdminInner extends React.PureComponent {
|
||||
{aboutMessagePreviewSupported ? (
|
||||
<CopyButton
|
||||
transformer={text =>
|
||||
`about:messagepreview?json=${encodeURIComponent(
|
||||
toBinary(text)
|
||||
)}`
|
||||
`about:messagepreview?json=${encodeURIComponent(btoa(text))}`
|
||||
}
|
||||
label="Share"
|
||||
copiedLabel="Copied!"
|
||||
|
@ -985,16 +985,6 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
||||
const Row = props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("tr", _extends({
|
||||
className: "message-item"
|
||||
}, props), props.children);
|
||||
|
||||
// Convert a UTF-8 string to a string in which only one byte of each
|
||||
// 16-bit unit is occupied. This is necessary to comply with `btoa` API constraints.
|
||||
function toBinary(string) {
|
||||
const codeUnits = new Uint16Array(string.length);
|
||||
for (let i = 0; i < codeUnits.length; i++) {
|
||||
codeUnits[i] = string.charCodeAt(i);
|
||||
}
|
||||
return btoa(String.fromCharCode(...Array.from(new Uint8Array(codeUnits.buffer))));
|
||||
}
|
||||
function relativeTime(timestamp) {
|
||||
if (!timestamp) {
|
||||
return "";
|
||||
@ -1437,7 +1427,7 @@ class ASRouterAdminInner extends (react__WEBPACK_IMPORTED_MODULE_1___default().P
|
||||
className: "button modify",
|
||||
onClick: () => this.modifyJson(msg)
|
||||
}, "Modify"), aboutMessagePreviewSupported ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_CopyButton__WEBPACK_IMPORTED_MODULE_4__.CopyButton, {
|
||||
transformer: text => `about:messagepreview?json=${encodeURIComponent(toBinary(text))}`,
|
||||
transformer: text => `about:messagepreview?json=${encodeURIComponent(btoa(text))}`,
|
||||
label: "Share",
|
||||
copiedLabel: "Copied!",
|
||||
inputSelector: `#${msg.id}-textarea`,
|
||||
|
@ -6,25 +6,13 @@
|
||||
|
||||
"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 fromBinary(encodedMessage);
|
||||
return atob(encodedMessage);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user