@viveeditor/sanitize 0.1.0 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.mts +23 -0
- package/dist/index.mjs +477 -48
- package/dist/index.mjs.map +1 -1
- package/dist/profile.json +68 -16
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ import { sanitizeHtml } from '@viveeditor/sanitize'
|
|
|
18
18
|
const clean = sanitizeHtml(request.body.html, { embeds: true })
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
Keeps exactly the HTML viveEditor produces and removes everything else, using a full HTML5 parser. HTML over `maxBytes` (2 MB by default) throws `TOO_LARGE`, hostile structure throws `TOO_COMPLEX`. The PHP package `viveeditor/sanitizer` shares the same allowlist and test corpus. See [Sanitize on the server](https://github.com/mtvrkan/viveeditor#sanitize-on-the-server).
|
|
21
|
+
Keeps exactly the HTML viveEditor produces and removes everything else, using a full HTML5 parser. HTML over `maxBytes` (2 MB by default) throws `TOO_LARGE`, hostile structure throws `TOO_COMPLEX`. Comment anchors (`<span data-vive-comment>`) are removed unless you pass `comments: 'keep'`, which you want when storing a draft that is edited again, not when publishing. Comment threads are validated with `cleanThreads` from `@viveeditor/ext-comments/threads`. Pending suggestions (`<ins data-vive-change>` and `<del data-vive-change>`) are published as approved text by default (`suggestions: 'reject'`: insertions removed, deletions kept as plain text); `'accept'` applies them and `'keep'` keeps them with validated attributes for a stored draft. Paragraph breaks of pending suggestions stay as breaks unless you keep them. The PHP package `viveeditor/sanitizer` shares the same allowlist and test corpus. See [Sanitize on the server](https://github.com/mtvrkan/viveeditor#sanitize-on-the-server).
|
|
22
22
|
|
|
23
23
|
## License
|
|
24
24
|
|
package/dist/index.d.mts
CHANGED
|
@@ -23,26 +23,45 @@ interface SanitizeProfile {
|
|
|
23
23
|
readonly maxUrlLength: number;
|
|
24
24
|
readonly maxTextAttributeLength: number;
|
|
25
25
|
readonly maxStyleValueLength: number;
|
|
26
|
+
readonly minFontSizePt: number;
|
|
27
|
+
readonly maxFontSizePt: number;
|
|
26
28
|
readonly maxSpan: number;
|
|
27
29
|
readonly maxImageSize: number;
|
|
28
30
|
readonly maxListStart: number;
|
|
29
31
|
readonly maxTableWidth: number;
|
|
32
|
+
readonly maxRowHeight: number;
|
|
30
33
|
readonly maxEmbedStart: number;
|
|
31
34
|
readonly maxEmbedTitle: number;
|
|
32
35
|
readonly maxMentionId: number;
|
|
33
36
|
readonly maxMentionLabel: number;
|
|
37
|
+
readonly maxCommentId: number;
|
|
38
|
+
readonly maxChangeId: number;
|
|
39
|
+
readonly maxAuthorId: number;
|
|
40
|
+
readonly maxAuthorName: number;
|
|
34
41
|
readonly maxMathLength: number;
|
|
35
42
|
readonly maxMathDepth: number;
|
|
36
43
|
readonly maxFootnoteLength: number;
|
|
37
44
|
readonly maxAttributes: number;
|
|
38
45
|
readonly maxNesting: number;
|
|
39
46
|
readonly maxExtraElements: number;
|
|
47
|
+
readonly maxTags: number;
|
|
40
48
|
};
|
|
41
49
|
readonly dropWithContent: readonly string[];
|
|
42
50
|
readonly elements: Readonly<Record<string, ElementRule>>;
|
|
43
51
|
readonly mentionClass: string;
|
|
44
52
|
readonly footnoteElements: readonly string[];
|
|
45
53
|
readonly textAlign: readonly string[];
|
|
54
|
+
readonly fontSizes: readonly string[];
|
|
55
|
+
readonly indents: readonly string[];
|
|
56
|
+
readonly imageAlign: readonly string[];
|
|
57
|
+
readonly verticalAlign: readonly string[];
|
|
58
|
+
readonly lineHeights: readonly string[];
|
|
59
|
+
readonly orderedListTypes: readonly string[];
|
|
60
|
+
readonly bulletStyles: readonly string[];
|
|
61
|
+
readonly tableWidths: readonly string[];
|
|
62
|
+
readonly tableAlign: readonly string[];
|
|
63
|
+
readonly tableBorders: readonly string[];
|
|
64
|
+
readonly fontFamilies: readonly string[];
|
|
46
65
|
readonly linkProtocols: readonly string[];
|
|
47
66
|
readonly linkRel: string;
|
|
48
67
|
readonly image: {
|
|
@@ -62,6 +81,10 @@ interface SanitizeOptions {
|
|
|
62
81
|
allowBase64?: boolean;
|
|
63
82
|
allowRelativeImages?: boolean;
|
|
64
83
|
maxBytes?: number;
|
|
84
|
+
maxTags?: number;
|
|
85
|
+
fontFamilies?: readonly string[];
|
|
86
|
+
comments?: "strip" | "keep";
|
|
87
|
+
suggestions?: "reject" | "accept" | "keep";
|
|
65
88
|
}
|
|
66
89
|
type SanitizeErrorCode = "TOO_LARGE" | "TOO_COMPLEX";
|
|
67
90
|
export declare class SanitizeError extends Error {
|