Skip to content

Build your personal knowledge base with Trilium Notes

Merge remote-tracking branch 'origin/stable'

zadamef59810f896a
diff --cc src/services/notes.js
index 0e547845e2,fd341214a9..d6eafe88e7
--- a/src/services/notes.js
+++ b/src/services/notes.js
@@@ -277,12 -277,18 +277,18 @@@ async function downloadImage(noteId, im
const downloadImagePromises = {};
function replaceUrl(content, url, imageNote) {
- const quotedUrl = utils.quoteRegex(url);
+ if (url.length > 2000) {
+ // for very large inline base64 images which fail on regex max size
+ return content.replace(url, `api/images/${imageNote.noteId}/${imageNote.title}`);
+ }
+ else {
+ const quotedUrl = utils.quoteRegex(url);
- return content.replace(new RegExp(`\\s+src=[\"']${quotedUrl}[\"']`, "g"), ` src="api/images/${imageNote.noteId}/${imageNote.title}"`);
+ return content.replace(new RegExp(`\\s+src=[\"']${quotedUrl}[\"']`, "g"), ` src="api/images/${imageNote.noteId}/${imageNote.title}"`);
+ }
}
-async function downloadImages(noteId, content) {
+function downloadImages(noteId, content) {
const re = /<img[^>]*?\ssrc=['"]([^'">]+)['"]/ig;
let match;