Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
hotfix: sanitize-html
Marc Seitz423fdda031ea
diff --git a/lib/constants.ts b/lib/constants.tsindex 80505088..ce2b6666 100644--- a/lib/constants.ts+++ b/lib/constants.ts@@ -65,6 +65,10 @@ export const LIMITS = {views: 20,};+// Lives here rather than next to the sanitizer so client components can read+// the limit without pulling `sanitize-html` into the browser/SSR bundle.+export const MAX_MESSAGE_LENGTH = 4000;+export const SUPPORTED_DOCUMENT_MIME_TYPES = ["application/pdf", // .pdf"application/vnd.ms-excel", // .xlsdiff --git a/lib/utils/sanitize-html.ts b/lib/utils/sanitize-html.tsindex e501e695..6d6544d1 100644--- a/lib/utils/sanitize-html.ts+++ b/lib/utils/sanitize-html.ts@@ -1,6 +1,8 @@import sanitizeHtml from "sanitize-html";import { decodeHTML } from "entities";+import { MAX_MESSAGE_LENGTH } from "@/lib/constants";+const plainTextSanitizeConfig = {allowedTags: [],allowedAttributes: {},@@ -19,8 +21,6 @@ export function sanitizePlainText(content: string) {.trim();}-export const MAX_MESSAGE_LENGTH = 4000;-export function validateContent(html: string, length: number = MAX_MESSAGE_LENGTH) {if (html.length > length) {throw new Error(`Content cannot be longer than ${length} characters`);diff --git a/package-lock.json b/package-lock.jsonindex 182de81f..eb682213 100644--- a/package-lock.json+++ b/package-lock.json@@ -145,7 +145,7 @@"react-textarea-autosize": "^8.5.9","react-zoom-pan-pinch": "^4.0.3","resend": "^6.12.3",- "sanitize-html": "^2.17.3",+ "sanitize-html": "2.17.5","shiki": "^3.23.0","sonner": "^2.0.7","streamdown": "^2.5.0",@@ -16671,7 +16671,6 @@},"node_modules/htmlparser2": {"version": "10.1.0",- "dev": true,"funding": ["https://github.com/fb55/htmlparser2?sponsor=1",{@@ -16689,7 +16688,6 @@},"node_modules/htmlparser2/node_modules/entities": {"version": "7.0.1",- "dev": true,"license": "BSD-2-Clause","engines": {"node": ">=0.12"@@ -23066,100 +23064,18 @@"license": "MIT"},"node_modules/sanitize-html": {- "version": "2.17.7",- "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.17.7.tgz",- "integrity": "sha512-PGtEkc9cbnedU3s9TmzDbpsZ8w086g/0Q8k8/oIO1NLNU3i5k9yn835CrjJSajp1KMmkisbO1qPXxNKO3welAg==",+ "version": "2.17.5",+ "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.17.5.tgz",+ "integrity": "sha512-ZmU1joGRrvoyctKIiuwUxqR6moLoU2Wk+2bMccN6f7UwhAmwYDvWziqPxRDDN2Qip62NqnIrVrT9akbL6Wretg==","license": "MIT","dependencies": {"deepmerge": "^4.2.2","escape-string-regexp": "^4.0.0",- "htmlparser2": "^12.0.0",+ "htmlparser2": "^10.1.0","is-plain-object": "^5.0.0","launder": "^1.7.1","parse-srcset": "^1.0.2","postcss": "^8.3.11"- },- "engines": {- "node": ">=22.12.0"- }- },- "node_modules/sanitize-html/node_modules/dom-serializer": {- "version": "3.1.1",- "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-3.1.1.tgz",- "integrity": "sha512-4MEa38/QexBob6gFNwu+EGdWvhJ1OKuNwdYY3Y3NyeWDQfnGeDYQUDfIRzWu5B5gsv03so2Uxd28YC6zrsx3Lw==",- "license": "MIT",- "dependencies": {- "domelementtype": "^3.0.0",- "domhandler": "^6.0.0",- "entities": "^8.0.0"- },- "engines": {- "node": ">=20.19.0"- },- "funding": {- "type": "github",- "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"- }- },- "node_modules/sanitize-html/node_modules/domelementtype": {- "version": "3.0.0",- "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-3.0.0.tgz",- "integrity": "sha512-umCQid3jKbDmVjx8jGaW7uUykm4DEUeyV21hPxNMo2nV955DhUThwqyOIDtreepP31hl84X7G5U9ZfsWvIB3Pg==",- "funding": [- {- "type": "github",- "url": "https://github.com/sponsors/fb55"- }- ],- "license": "BSD-2-Clause",- "engines": {- "node": ">=20.19.0"- }- },- "node_modules/sanitize-html/node_modules/domhandler": {- "version": "6.0.1",- "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-6.0.1.tgz",- "integrity": "sha512-gYzvtM72ZtxQO0T048kd6HWSbbGCNOUwcnfQ01cqIJ4X2IYKFFHZ5mKvrQETcFXxsRObZulDaKmy//R7TPtsBg==",- "license": "BSD-2-Clause",- "dependencies": {- "domelementtype": "^3.0.0"- },- "engines": {- "node": ">=20.19.0"- },- "funding": {- "type": "github",- "url": "https://github.com/fb55/domhandler?sponsor=1"- }- },- "node_modules/sanitize-html/node_modules/domutils": {- "version": "4.0.2",- "resolved": "https://registry.npmjs.org/domutils/-/domutils-4.0.2.tgz",- "integrity": "sha512-qI4JLRKnSzqFqr7hAlS5xQDusBCjKSEG4t4+7aNrIQMHBcsC2TGEhuyABJdYkgSewL57PNLYEiibY2iPKhKpaA==",- "license": "BSD-2-Clause",- "dependencies": {- "dom-serializer": "^3.0.0",- "domelementtype": "^3.0.0",- "domhandler": "^6.0.0"- },- "engines": {- "node": ">=20.19.0"- },- "funding": {- "type": "github",- "url": "https://github.com/fb55/domutils?sponsor=1"- }- },- "node_modules/sanitize-html/node_modules/entities": {- "version": "8.0.0",- "resolved": "https://registry.npmjs.org/entities/-/entities-8.0.0.tgz",- "integrity": "sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==",- "license": "BSD-2-Clause",- "engines": {- "node": ">=20.19.0"- },- "funding": {- "url": "https://github.com/fb55/entities?sponsor=1"}},"node_modules/sanitize-html/node_modules/escape-string-regexp": {@@ -23172,28 +23088,6 @@"url": "https://github.com/sponsors/sindresorhus"}},- "node_modules/sanitize-html/node_modules/htmlparser2": {- "version": "12.0.0",- "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-12.0.0.tgz",- "integrity": "sha512-Tz7u1i95/g2x2jz81+x0FBVhBhY5aRTvD3tXXdFaljuNdzDLJ8UGNRrTcj2cgQvAg3iW/h77Fz15nLW0L0CrZw==",- "funding": [- "https://github.com/fb55/htmlparser2?sponsor=1",- {- "type": "github",- "url": "https://github.com/sponsors/fb55"- }- ],- "license": "MIT",- "dependencies": {- "domelementtype": "^3.0.0",- "domhandler": "^6.0.0",- "domutils": "^4.0.2",- "entities": "^8.0.0"- },- "engines": {- "node": ">=20.19.0"- }- },"node_modules/sax": {"version": "1.6.0","license": "BlueOak-1.0.0",diff --git a/package.json b/package.jsonindex f79d1722..f430a2d0 100644--- a/package.json+++ b/package.json@@ -158,7 +158,7 @@"react-textarea-autosize": "^8.5.9","react-zoom-pan-pinch": "^4.0.3","resend": "^6.12.3",- "sanitize-html": "^2.17.3",+ "sanitize-html": "2.17.5","shiki": "^3.23.0","sonner": "^2.0.7","streamdown": "^2.5.0",