feat: added an URL sanitizer

This commit is contained in:
2026-02-22 17:55:42 +01:00
parent 509afa4c85
commit 145b3ea0a6
4 changed files with 23 additions and 1 deletions

View File

@@ -25,6 +25,14 @@ describe('blogmark deep-link payload', () => {
expect(payload).toBeNull();
});
it('rejects entity-obfuscated script URLs', () => {
const payload = extractBlogmarkPayloadFromDeepLink(
'bds://new-post?title=Unsafe&url=javascript%26%2397%3Balert(1)',
);
expect(payload).toBeNull();
});
it('builds safe markdown source link', () => {
const markdown = buildBlogmarkMarkdownLink('A [title] (test)', 'https://example.com/x?y=1');
expect(markdown).toBe('[A \\[title\\] \\(test\\)](<https://example.com/x?y=1>)');