mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-25 08:35:16 +08:00
fix(inline-attachments): Handle images with UTF16 names
This commit is contained in:
parent
8332ecf95e
commit
b758ffe589
1 changed files with 10 additions and 2 deletions
|
@ -1,9 +1,17 @@
|
|||
import {Actions, Utils} from 'nylas-exports';
|
||||
|
||||
function safeEncode(str) {
|
||||
return btoa(unescape(encodeURIComponent(str)));
|
||||
}
|
||||
|
||||
function safeDecode(str) {
|
||||
return atob(decodeURIComponent(escape(str)))
|
||||
}
|
||||
|
||||
function _runOnImageNode(node) {
|
||||
if (node.src && node.dataset.nylasFile) {
|
||||
node.addEventListener('error', () => {
|
||||
const file = JSON.parse(atob(node.dataset.nylasFile), Utils.registeredObjectReviver);
|
||||
const file = JSON.parse(safeDecode(node.dataset.nylasFile), Utils.registeredObjectReviver);
|
||||
const initialDisplay = node.style.display;
|
||||
const downloadButton = document.createElement('a');
|
||||
downloadButton.classList.add('inline-download-prompt')
|
||||
|
@ -22,7 +30,7 @@ function _runOnImageNode(node) {
|
|||
}
|
||||
|
||||
export function encodedAttributeForFile(file) {
|
||||
return btoa(JSON.stringify(file, Utils.registeredObjectReplacer));
|
||||
return safeEncode(JSON.stringify(file, Utils.registeredObjectReplacer));
|
||||
}
|
||||
|
||||
export function addInlineDownloadPrompts(doc) {
|
||||
|
|
Loading…
Reference in a new issue