fix: Update image dimensions in markdown test and enhance URL sanitization

This commit is contained in:
2026-05-10 19:23:01 +10:00
parent f56a1e9181
commit 628adc59ee
2 changed files with 2 additions and 2 deletions

View File

@@ -102,7 +102,7 @@ const obj = {
## Images
![0.50](data/blog/media/test.gif "Caption Test")
![1.00](data/blog/media/test.gif "Caption Test")
![0.26](data/blog/media/paste-1778404389024-jnpo3.jpeg)

View File

@@ -402,7 +402,7 @@ export class MarkdownRenderer {
static #sanitizeUrl(url) {
const trimmed = url.trim();
// Allow absolute URLs, root-relative, hash links, relative-dot paths, and plain relative paths
if (/^(https?:\/\/|mailto:|\/|#|\.)/.test(trimmed)) return trimmed;
if (/^(https?:\/\/|mailto:|blob:|\/|#|\.)/.test(trimmed)) return trimmed;
// Allow relative paths (e.g. data/blog/media/image.png) — no protocol = safe relative
if (/^[a-zA-Z0-9_\-][a-zA-Z0-9_.\-\/]*$/.test(trimmed)) return trimmed;
return null;