fix(pdf): security hardening — hex-encoded link URIs, strict branding URL schema, branding and labels re-validated at export, PNG dimension budget, CSS escape and parenthesis rules in the sanitiser, finite raster size, file size checked before read
This commit is contained in:
1 parent
4930704d8a
commit
1f417b21fd
12 files changed
+437
-25
No files matched your search
@@ -10,11 +10,19 @@ import { z } from 'zod'
|
||||
const KIB = 1024
|
||||
const BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/
|
||||
|
||||
/**
|
||||
* `http(s)://` then printable ASCII without `"`, `'`, `(`, `)`, `<`, `>`
|
||||
* or `\`: the URL is written into PDF link actions and must never be able
|
||||
* to close a string literal or carry a control character. Expressed as the
|
||||
* allowed ranges of printable ASCII (0x21-0x7e) minus those seven.
|
||||
*/
|
||||
const HTTP_URL_PATTERN = /^https?:\/\/[!#-&*-;=?-[\]-~]+$/
|
||||
|
||||
const HttpUrlSchema = z
|
||||
.string()
|
||||
.max(2048)
|
||||
.url()
|
||||
.refine((url) => /^https?:\/\//i.test(url), 'http(s) URL expected')
|
||||
.regex(HTTP_URL_PATTERN, 'http(s) URL expected')
|
||||
|
||||
export const ImageAssetSchema = z.discriminatedUnion('kind', [
|
||||
z
|
||||
|
||||
Reference in new issue
Block a user