feat: certification rules, content sanitization, handle draft course updates and reset content, better redis logging

This commit is contained in:
Rotimi Best
2026-03-30 08:24:55 +01:00
parent ff2ad59377
commit 5a8f50f67b
131 changed files with 5643 additions and 2134 deletions
+1
View File
@@ -1,3 +1,4 @@
export * from './array';
export * from './fileValidation';
export * from './sanitize';
export * from './slug';
+50
View File
@@ -0,0 +1,50 @@
export const FORBID_TAGS = [
'script',
'iframe',
'object',
'embed',
'form',
'input',
'textarea',
'select',
'button',
'meta',
'link',
'svg',
'math'
] as const;
export const FORBID_ATTR = [
'onerror',
'onload',
'onclick',
'onmouseover',
'onfocus',
'onblur',
'onchange',
'onsubmit',
'onreset',
'onselect',
'onunload'
] as const;
export const ADD_ATTR = ['data-type', 'data-latex', 'colwidth'] as const;
export const ALLOWED_URI_REGEXP =
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i;
export function createSanitizeHtmlConfig() {
return {
FORBID_TAGS: [...FORBID_TAGS],
FORBID_ATTR: [...FORBID_ATTR],
ADD_ATTR: [...ADD_ATTR],
KEEP_CONTENT: true,
SANITIZE_DOM: true,
ALLOW_DATA_ATTR: false,
ALLOWED_URI_REGEXP
};
}
export function stripSvgDataUrls(html: string): string {
return html.replace(/src\s*=\s*["']data:image\/svg[^"']*["']/gi, 'src=""');
}