diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index 5bd662ccb..0b51d4ba3 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -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); diff --git a/dev/Mime/Parser.js b/dev/Mime/Parser.js index 4a9cbaa65..9ce19775b 100644 --- a/dev/Mime/Parser.js +++ b/dev/Mime/Parser.js @@ -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; } diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 2d6d8b354..3e3131e75 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -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, diff --git a/plugins/avatars/avatars.js b/plugins/avatars/avatars.js index 8b969b51c..fe6855503 100644 --- a/plugins/avatars/avatars.js +++ b/plugins/avatars/avatars.js @@ -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);