A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: handle "bad base-64" error
thecodrr5bc353f9858c
diff --git a/packages/core/content-types/tiny.js b/packages/core/content-types/tiny.jsindex b6646c05e..44472654f 100644--- a/packages/core/content-types/tiny.js+++ b/packages/core/content-types/tiny.js@@ -87,42 +87,51 @@ class Tiny {for (var i = 0; i < attachmentElements.length; ++i) {const attachment = attachmentElements[i];- switch (attachment.tagName) {- case "IMG": {- if (!getDatasetAttribute(attachment, "hash")) {- const src = attachment.getAttribute("src");- if (!src) continue;-- const { data, mime } = dataurl.toObject(src);- if (!data) continue;-- const type =- getDatasetAttribute(attachment, "mime") || mime || "image/jpeg";- const { key, metadata } = await store(data, "base64");- setDatasetAttribute(attachment, "hash", metadata.hash);-- attachments.push({- type,- filename:- getDatasetAttribute(attachment, "filename") || metadata.hash,- ...metadata,- key,- });- } else {+ try {+ switch (attachment.tagName) {+ case "IMG": {+ if (!getDatasetAttribute(attachment, "hash")) {+ const src = attachment.getAttribute("src");+ if (!src) continue;++ const { data, mime } = dataurl.toObject(src);+ if (!data) continue;++ const type =+ getDatasetAttribute(attachment, "mime") || mime || "image/jpeg";+ const { key, metadata } = await store(data, "base64");+ setDatasetAttribute(attachment, "hash", metadata.hash);++ attachments.push({+ type,+ filename:+ getDatasetAttribute(attachment, "filename") || metadata.hash,+ ...metadata,+ key,+ });+ } else {+ attachments.push({+ hash: getDatasetAttribute(attachment, "hash"),+ });+ }+ attachment.removeAttribute("src");+ break;+ }+ default: {+ if (!getDatasetAttribute(attachment, "hash")) continue;attachments.push({hash: getDatasetAttribute(attachment, "hash"),});+ break;}- attachment.removeAttribute("src");- break;}- default: {- if (!getDatasetAttribute(attachment, "hash")) continue;- attachments.push({- hash: getDatasetAttribute(attachment, "hash"),- });- break;+ } catch (e) {+ if (e.message === "bad base-64") {+ attachment.remove();+ console.error(e);+ continue;}+ throw e;}}return { data: document.outerHTML || document.body.innerHTML, attachments };