Skip to content

Preview does not render embedded images (YouTube thumbnails) and escapes raw HTML #10

Closed

Description

@gnacho

Problem

Notes containing image embeds do not render in the preview:

  1. Raw HTML in note content (the common YouTube thumbnail pattern: an <a> wrapping an <img src="http://img.youtube.com/vi/ID/0.jpg">) is escaped and shown as literal text, because the markdown renderer runs with html: false.
  2. Even when rendered, the host CSP restricts img-src to 'self' plus a small allowlist, so external images are blocked.

Proposed fix

  • Backend: signed image proxy (HMAC-SHA256 with a per-instance secret, disk cache, size cap, SSRF-guarded transport) exposing:
    • GET /img?u=<url>&t=<sig> public (the <img> tag carries no auth headers)
    • POST /img/sign authenticated, returns proxied URLs for a batch of image URLs
  • Frontend: render preview with raw HTML enabled but sanitized through DOMPurify; rewrite external image URLs to their signed proxied version before rendering; open links in a new tab.

Note content itself stays untouched (original URLs remain editable); rewriting happens at render time only.

Embedded video players (iframes) remain impossible under the host CSP; the thumbnail-link pattern is the supported outcome.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions