From 9b420ac103979dc211f6d99acde653061b6ea0ed Mon Sep 17 00:00:00 2001 From: S1m Date: Tue, 4 Jun 2024 10:43:57 +0200 Subject: [PATCH] Fix relative image url fetched from stylesheet domain Partial URLs are interpreted relative to the source of the style sheet, not relative to the document https://www.w3.org/TR/CSS1/ --- src/js/easymde.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/js/easymde.js b/src/js/easymde.js index de0d9750..2734dbcd 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -2233,8 +2233,9 @@ EasyMDE.prototype.render = function (el) { function assignImageBlockAttributes(parentEl, img) { - parentEl.setAttribute('data-img-src', img.url); - parentEl.setAttribute('style', '--bg-image:url(' + img.url + ');--width:' + img.naturalWidth + 'px;--height:' + calcHeight(img.naturalWidth, img.naturalHeight)); + var url = (new URL(img.url, document.baseURI)).href; + parentEl.setAttribute('data-img-src', url); + parentEl.setAttribute('style', '--bg-image:url(' + url + ');--width:' + img.naturalWidth + 'px;--height:' + calcHeight(img.naturalWidth, img.naturalHeight)); _vm.codemirror.setSize(); }