mirror of
https://github.com/litruv/lit.ruv.wtf.git
synced 2026-11-29 01:45:46 +11:00
fix: Update URL sanitization logic in Markdown renderer
This commit is contained in:
1 parent
4e4665c4ca
commit
01bac4c0bd
1 file changed
+1
-1
@@ -402,7 +402,7 @@ export class MarkdownRenderer {
|
|||||||
static #sanitizeUrl(url) {
|
static #sanitizeUrl(url) {
|
||||||
const trimmed = url.trim();
|
const trimmed = url.trim();
|
||||||
// Allow absolute URLs, root-relative, hash links, relative-dot paths, and plain relative paths
|
// Allow absolute URLs, root-relative, hash links, relative-dot paths, and plain relative paths
|
||||||
if (/^(https?:\/\/|mailto:|blob:|\/|#|\.)/.test(trimmed)) return trimmed;
|
if (/^(https?:\/\/|mailto:|\/|#|\.)/.test(trimmed)) return trimmed;
|
||||||
// Allow relative paths (e.g. data/blog/media/image.png) — no protocol = safe relative
|
// 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;
|
if (/^[a-zA-Z0-9_\-][a-zA-Z0-9_.\-\/]*$/.test(trimmed)) return trimmed;
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in new issue
Block a user