Resolve #967 btoa() issue

This commit is contained in:
the-djmaze 2023-02-15 17:29:47 +01:00
parent 03379a6163
commit 4852895488
4 changed files with 11 additions and 6 deletions

View file

@ -17,12 +17,15 @@ export const
item && undefined !== item.disabled && domItem?.classList.toggle('disabled', domItem.disabled = item.disabled),
// unescape(encodeURIComponent()) makes the UTF-16 DOMString to an UTF-8 string
b64EncodeJSON = data => btoa(unescape(encodeURIComponent(JSON.stringify(data)))),
b64Encode = data => btoa(unescape(encodeURIComponent(data))),
/* // Without deprecated 'unescape':
b64EncodeJSON = data => btoa(encodeURIComponent(JSON.stringify(data)).replace(
b64Encode = data => btoa(encodeURIComponent(data).replace(
/%([0-9A-F]{2})/g, (match, p1) => String.fromCharCode('0x' + p1)
)),
*/
b64EncodeJSON = data => b64Encode(JSON.stringify(data)),
b64EncodeJSONSafe = data => b64EncodeJSON(data).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''),
getKeyByValue = (o, v) => Object.keys(o).find(key => o[key] === v);

View file

@ -1,3 +1,4 @@
//import { b64Encode } from 'Common/Utils';
const
// RFC2045
@ -68,6 +69,7 @@ export function ParseMime(text)
body = QPDecode(body);
}
body = btoa(body);
// body = b64Encode(body);
}
return 'data:' + this.headerValue('content-type') + ';base64,' + body;
}

View file

@ -11,7 +11,7 @@ import {
FolderType
} from 'Common/EnumsUser';
import { pInt, isArray, arrayLength } from 'Common/Utils';
import { pInt, isArray, arrayLength, b64Encode } from 'Common/Utils';
import { encodeHtml, HtmlEditor, htmlToPlain } from 'Common/Html';
import { koArrayWithDestroy, addObservablesTo, addComputablesTo, addSubscribablesTo } from 'External/ko';
@ -57,7 +57,7 @@ const
tpl = createElement('template'),
base64_encode = text => btoa(unescape(encodeURIComponent(text))).match(/.{1,76}/g).join('\r\n'),
base64_encode = text => b64Encode(text).match(/.{1,76}/g).join('\r\n'),
getEmail = value => addressparser(value)[0]?.email || false,

View file

@ -63,11 +63,11 @@
.slice(0,2)
.toUpperCase(),
setIdenticon = (from, fn) => hash(from.email).then(hash =>
fn('data:image/svg+xml;base64,' + btoa(window.identiconSvg(
fn('data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(window.identiconSvg(
hash,
fromChars(from),
window.getComputedStyle(getEl('rl-app'), null).getPropertyValue('font-family')
)))
)))))
),
addQueue = (msg, fn) => {
msg.from?.[0] && setIdenticon(msg.from[0], fn);