parley-markup 0.6.0

Renders untrusted markdown from Parley messages into a typed node tree that cannot carry markup.
Documentation
  • Coverage
  • 12.2%
    5 out of 41 items documented0 out of 4 items with examples
  • Size
  • Source code size: 26.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 416.1 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tylerthebuildor

Renders untrusted markdown into a typed tree that cannot carry markup.

Message bodies are attacker-controlled. In the CLI they land in a terminal; in a webview they land somewhere that can execute code, and a sender who achieves script execution there is inside the trust boundary and can read and exfiltrate every conversation. That is strictly worse than compromising the relay, which only ever sees ciphertext.

So this crate never produces an HTML string. It produces [Node] and [Inline] values that a renderer maps to elements, which means there is no string for an injection to hide in and no innerHTML at the far end. Three rules do the work:

  1. Raw HTML is text, not markup. pulldown-cmark emits embedded HTML as its own event; those become [Inline::Text] verbatim. A body containing <script> renders those characters on screen.
  2. Link targets are allowlisted to http, https, and mailto. Anything else (javascript:, data:, vbscript:, file:) loses its link and keeps its text, so the content survives and the navigation does not.
  3. Remote images are not fetched. This is privacy, not just safety: an inlined remote image is a read receipt telling the sender when you opened a message and from which IP. They arrive as [ImageSource::Blocked] for the UI to offer as click-to-load.