HTML and security
Which raw HTML a LibreTimes document may contain, what the sanitizer removes, and why scripts, styles, frames and social-media embeds are refused.
Markdown allows raw HTML in the source, and LibreTimes keeps a controlled subset of it. Everything a document renders — Markdown-generated and hand-written HTML alike — passes through sanitization on an allowlist basis: what is not explicitly allowed is removed.
Raw HTML you can use
Markdown syntax covers almost everything, so raw HTML is rarely needed. The useful allowed cases:
| Element | Why you might write it |
|---|---|
<details> / <summary> |
collapsible section; same result as the spoiler directive |
<sub> / <sup> |
subscript/superscript, equivalent to ~x~ / ^x^ |
<mark> |
highlight, equivalent to ==x== |
<kbd> |
keyboard keys: Ctrl+K |
<table>, <thead>, <tbody>, <tr>, <th>, <td> |
tables that need rowspan/colspan beyond GFM syntax |
<img width="..." height="..."> |
an image with explicit dimensions |
<br>, <hr>, <blockquote>, <dl>/<dt>/<dd> |
standard structure, same as their Markdown forms |
Standard inline and block elements (<b>, <i>, <em>, <strong>,
<code>, <pre>, <p>, <ul>, <ol>, <li>, headings, and similar) are
allowed too — prefer the Markdown forms for readability.
What sanitization removes
- Scripts and handlers:
<script>,<style>, and everyon*event attribute. There is no way to execute code from a document. - Dangerous URLs: link
hrefs outsidehttps/http/mailtoand imagesrcs outsidehttps/http(nojavascript:, nodata:). - Frames:
<iframe>survives only as produced by video embeds, withsrcrestricted toyoutube-nocookie.comandplayer.vimeo.com. Any other frame is removed entirely. - Free-form styling:
styleattributes, with a pinned exception for the video player's own sizing. A document cannot restyle the page around it. - Everything unlisted:
<form>,<input>,<object>,<embed>,<canvas>, custom elements — removed, along with unlisted attributes on allowed elements.
Removal is silent: the disallowed node disappears from the rendered page rather than producing an error.
HTML comments are not kept
A comment, <!-- like this -->, is removed when you save — it never reaches
storage. A hidden note is not a private one: the page would not show it, but
anyone reading the work through the API, the lt command line or an AI
assistant receives the text as it is stored, comment and all. For a note to
yourself, use a private note on the
passage instead; it is kept beside the text, never in it.
A <!-- you show as an example inside inline code, a code block or a formula
is text, and stays exactly as you wrote it. A <!-- that is never closed is
kept as visible text rather than hiding the rest of the document. When an
assistant saves an edit, it is told how many comments were removed.
Why these rules
Every rule above closes one way a document could act on its reader instead of informing them. A page on LibreTimes shows text by people the reader has never met, so the text must not be able to do anything a reader did not ask for.
- No scripts, because a document is read, not run. A script in a publication would run with the reader's session on this site: it could act as them, read what they can read, or rewrite the page under them. No feature of a lecture note needs that, so no script runs, whoever wrote it.
- No free styling, because the page around the text is not the author's.
A
styleattribute can paint a block over the whole window, imitate a sign-in box, or hide text from a reader while leaving it for a search engine. The dialect describes what a block is, and the page decides how it looks, which is also why dark mode and a phone screen work for every document. - Only two players, because a frame is someone else's page inside ours. An embedded frame loads its own scripts and its own cookies, and from that moment the reader is reading two sites. YouTube's privacy-enhanced player and Vimeo's player are the exceptions, held to their exact addresses, and they load only when the reader starts the video.
- Posts are links, never embeds. A post from X, Mastodon, Bluesky or any other network is not embedded, even as a card. An embed would either load the network's own script, which follows the reader across the web, or copy the post onto our page, where it would go on showing after its author deleted it. Quote the words you need in a blockquote and link to the post.
- Prefixed ids, because the page has ids of its own. An
idwritten in a document could otherwise take the name of a part of the page, or of something the page's scripts look up, and change what they do. Withuser-content-in front, a document's anchors live in a space of their own.
These rules are applied to the finished HTML, after your Markdown has become HTML, so they hold the same way for HTML you write by hand and for HTML the renderer writes from your Markdown.
Notes for authors
- Element
ids you write in raw HTML are prefixed withuser-content-in the output (a standard defense against DOM clobbering). Heading anchors are generated automatically, so you rarely need your own ids. - If something you wrote is missing from the rendered page, it was most likely sanitized. Check this page's lists; the Markdown-native form of the same structure is usually the answer.
- Sanitization is not a substitute for judgment about content — it stops code, not claims. Community standards live in the acceptable use policy.