mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-07 08:31:01 +01:00
fix(email): validate and escape unwrapped SafeLinks URLs before rendering
This commit is contained in:
+10
-1
@@ -331,7 +331,16 @@ export function sanitizeEmailHtml(html: string): string {
|
||||
(match, encodedUrl) => {
|
||||
try {
|
||||
const decodedUrl = decodeURIComponent(encodedUrl);
|
||||
return `href="${decodedUrl}"`;
|
||||
let parsed: URL;
|
||||
try {
|
||||
parsed = new URL(decodedUrl);
|
||||
} catch {
|
||||
return match;
|
||||
}
|
||||
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
||||
return match;
|
||||
}
|
||||
return `href="${escapeHtml(decodedUrl)}"`;
|
||||
} catch {
|
||||
return match;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user