diff --git a/docs/docs/documentation/getting-started/installation/backend-config.md b/docs/docs/documentation/getting-started/installation/backend-config.md index 27dae3885..6b030c0fc 100644 --- a/docs/docs/documentation/getting-started/installation/backend-config.md +++ b/docs/docs/documentation/getting-started/installation/backend-config.md @@ -29,6 +29,7 @@ | --------------------------- | :-----: | ----------------------------------------------------------------------------------- | | SECURITY_MAX_LOGIN_ATTEMPTS | 5 | Maximum times a user can provide an invalid password before their account is locked | | SECURITY_USER_LOCKOUT_TIME | 24 | Time in hours for how long a users account is locked | +| ALLOWED_IFRAME_HOSTS | `""` | Comma-separated extra hostnames allowed as `", []); + expect(html).not.toContain(" { + const html = sanitizeMarkdownHtml( + "", + ["youtube.com"], + ); + expect(html).not.toContain(" { + const html = sanitizeMarkdownHtml( + "", + ["youtube.com"], + ); + expect(html).not.toContain(" { + const html = sanitizeMarkdownHtml( + "", + ["youtube.com"], + ); + expect(html).toContain(" { + const html = sanitizeMarkdownHtml( + "", + ["youtube.com"], + ); + expect(html).not.toContain("; added to the allowlist solely when iframe embeds +// are enabled via a configured host allowlist. +const IFRAME_ALLOWED_ATTR = ["allow", "allowfullscreen", "frameborder", "scrolling"]; + +/** + * Returns true if an iframe `src` points at one of the allowed hosts. Only https URLs are + * accepted, and a configured host matches the URL's hostname exactly or as a parent domain + * (e.g. "youtube.com" matches "www.youtube.com"). + */ +function isAllowedIframeSrc(src: string, allowedHosts: string[]): boolean { + let url: URL; + try { + url = new URL(src); + } + catch { + return false; + } + + if (url.protocol !== "https:") { + return false; + } + + const hostname = url.hostname.toLowerCase(); + return allowedHosts.some((host) => { + const allowed = host.toLowerCase(); + return hostname === allowed || hostname.endsWith(`.${allowed}`); + }); +} + +/** + * Sanitizes pre-rendered HTML (from markdown) for display in user content such as recipe + * instructions, notes, and descriptions. + * + * Only the tags in `BASE_ALLOWED_TAGS` and attributes in `BASE_ALLOWED_ATTR` survive; everything + * else (scripts, event handlers, form controls, ...) is dropped. `style` attributes are filtered + * down to the properties in `ALLOWED_STYLE_PROPERTIES`. `