Source
This app’s code and revision history are public. Download a copy or explore the files below.
Public
The app’s code and revision history are public.
Run it yourself
Take the whole tree and run it on your own machine. The download needs no account. Cloning needs a sign-in.
Download .zip
bounded clone 6eca480d6447d873e2e5eed9
A copy you download is not bounded. The guarantees this app runs under - declared egress, proven invariants, writes that fail closed - live in the runtime serving this page, not in the files. What you get is auditable source you can read and run, with no runtime guarantees attached.
src/lib/markdown.ts
// Rendered Markdown, loaded only when someone views a Markdown paste rendered. Raw HTML is cleaned by
// DOMPurify, and images become links so a paste cannot load anything from another site when opened.
import { Marked } from "marked";
import DOMPurify from "dompurify";
import { escapeHtml } from "./highlight";
const marked = new Marked({
gfm: true,
async: false,
renderer: {
image({ href, text }) {
return `<a href="${escapeHtml(href).replace(/"/g, """)}">${escapeHtml(text || "Image")} (image)</a>`;
},
},
});
DOMPurify.addHook("afterSanitizeAttributes", (node) => {
if (node.tagName === "A") {
node.setAttribute("target", "_blank");
node.setAttribute("rel", "noopener noreferrer nofollow ugc");
}
});
export function renderMarkdown(text: string): string {
return DOMPurify.sanitize(marked.parse(text) as string, {
FORBID_TAGS: ["img", "style", "form", "input", "button", "textarea", "select", "iframe", "video", "audio", "source", "picture", "svg", "math"],
FORBID_ATTR: ["style", "srcset"],
});
}
Change history
Quality pass: password lock, year expiry, line links, text/plain API
Bounded source sync
Bounded source sync
Bounded source sync