max / makenotwork
| 1 | //! Markdown rendering helpers for creator content. |
| 2 | //! |
| 3 | //! Wraps `docengine` with media URL rewriting so relative image/video |
| 4 | //! references in markdown (``) resolve to CDN URLs. |
| 5 | //! |
| 6 | //! Sanitization policy (deliberate, ultra-fuzz Run 4 decision 2026-06-23): creator |
| 7 | //! markdown (blog posts, issues, project sections) is rendered via |
| 8 | //! `docengine::render_permissive`, which runs `ammonia` (strips script / |
| 9 | //! event-handlers / dangerous URL schemes) but PERMITS ordinary external |
| 10 | //! `http(s)`/`mailto` links, creators legitimately link out from prose. This is |
| 11 | //! intentionally MORE permissive than the custom-pages surface, which uses a |
| 12 | //! closed-system sanitizer restricting URLs to on-platform targets. Both paths are |
| 13 | //! XSS-safe; they differ only in whether external links are allowed, and that |
| 14 | //! difference is by design (long-form prose vs. a templated page builder). Keep the |
| 15 | //! two policies distinct rather than collapsing them. |
| 16 | |
| 17 | use crateUserId; |
| 18 | |
| 19 | /// Render creator-authored markdown to HTML with media URL resolution. |
| 20 | /// |
| 21 | /// Pipeline: |
| 22 | /// 1. Rewrite relative `` references to absolute CDN URLs |
| 23 | /// 2. Render markdown to HTML via `docengine::render_permissive` |
| 24 | /// 3. Strip off-platform media loads (tracking pixels) via |
| 25 | /// `docengine::restrict_media_hosts` |
| 26 | /// 4. Convert `<img>` tags with video extensions to `<video>` elements |
| 27 | |
| 28 | let md = rewrite_media_paths; |
| 29 | let html = render_permissive; |
| 30 | // Strip off-platform media loads (tracking pixels) while keeping external |
| 31 | // text links, fuzz 2026-07-06 UX. Runs on the `<img>` output, before the |
| 32 | // img->video conversion. Relative + CDN-host media stay. |
| 33 | let html = restrict_media_hosts; |
| 34 | img_to_video |
| 35 | |
| 36 |