security: sync upstream XSS fix + moderation history (reports SET NULL)

- renderMarkdown: sanitize marked output with sanitize-html (allowed
  tags/attrs whitelist, http/https schemes only, strip on* attrs) —
  prevents stored XSS in posts/replies/signatures
- schema: reports.post_id ON DELETE CASCADE → SET NULL (keep moderation
  history when a reported post is deleted); migration applied to prod DB
This commit is contained in:
lezi-fun committed 2026-08-11 17:06:56 +08:00
1 parent 7cc1f0e228
commit 7cdb7c1ac2
4 files changed
+63 -6

No files matched your search

+1 -1
View File
@@ -49,7 +49,7 @@ CREATE TABLE IF NOT EXISTS friendly_links (
-- 举报表
CREATE TABLE IF NOT EXISTS reports (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
post_id UUID NOT NULL REFERENCES posts(id) ON DELETE CASCADE,
post_id UUID REFERENCES posts(id) ON DELETE SET NULL,
reporter_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
reason VARCHAR(100) NOT NULL,
status VARCHAR(20) DEFAULT 'pending' CHECK (status IN ('pending', 'approved', 'rejected')),