1 | import { ParserOptions } from "htmlparser2";
|
2 |
|
3 | export = sanitize;
|
4 |
|
5 | declare function sanitize(dirty: string, options?: sanitize.IOptions): string;
|
6 |
|
7 | declare namespace sanitize {
|
8 | interface Attributes {
|
9 | [attr: string]: string;
|
10 | }
|
11 |
|
12 | interface Tag {
|
13 | tagName: string;
|
14 | attribs: Attributes;
|
15 | text?: string | undefined;
|
16 | }
|
17 |
|
18 | type Transformer = (tagName: string, attribs: Attributes) => Tag;
|
19 |
|
20 | type AllowedAttribute = string | { name: string; multiple?: boolean | undefined; values: string[] };
|
21 |
|
22 | type DisallowedTagsModes = "discard" | "escape" | "recursiveEscape" | "completelyDiscard";
|
23 |
|
24 |
|
25 | interface IDefaults {
|
26 | allowedAttributes: Record<string, AllowedAttribute[]>;
|
27 | allowedSchemes: string[];
|
28 | allowedSchemesByTag: { [index: string]: string[] };
|
29 | allowedSchemesAppliedToAttributes: string[];
|
30 | allowedTags: string[];
|
31 | allowProtocolRelative: boolean;
|
32 | disallowedTagsMode: DisallowedTagsModes;
|
33 | enforceHtmlBoundary: boolean;
|
34 | selfClosing: string[];
|
35 | nonBooleanAttributes: string[];
|
36 | }
|
37 |
|
38 |
|
39 | interface IFrame {
|
40 | tag: string;
|
41 | attribs: { [index: string]: string };
|
42 | text: string;
|
43 | tagPosition: number;
|
44 | mediaChildren: string[];
|
45 | }
|
46 |
|
47 |
|
48 | interface IOptions {
|
49 | allowedAttributes?: Record<string, AllowedAttribute[]> | false | undefined;
|
50 | allowedStyles?: { [index: string]: { [index: string]: RegExp[] } } | undefined;
|
51 | allowedClasses?: { [index: string]: boolean | Array<string | RegExp> } | undefined;
|
52 | allowedIframeDomains?: string[] | undefined;
|
53 | allowedIframeHostnames?: string[] | undefined;
|
54 | allowIframeRelativeUrls?: boolean | undefined;
|
55 | allowedSchemes?: string[] | boolean | undefined;
|
56 | allowedSchemesByTag?: { [index: string]: string[] } | boolean | undefined;
|
57 | allowedSchemesAppliedToAttributes?: string[] | undefined;
|
58 | allowedScriptDomains?: string[] | undefined;
|
59 | allowedScriptHostnames?: string[] | undefined;
|
60 | allowProtocolRelative?: boolean | undefined;
|
61 | allowedTags?: string[] | false | undefined;
|
62 | allowVulnerableTags?: boolean | undefined;
|
63 | textFilter?: ((text: string, tagName: string) => string) | undefined;
|
64 | exclusiveFilter?: ((frame: IFrame) => boolean) | undefined;
|
65 | nestingLimit?: number | undefined;
|
66 | nonTextTags?: string[] | undefined;
|
67 | /** @default true */
|
68 | parseStyleAttributes?: boolean | undefined;
|
69 | selfClosing?: string[] | undefined;
|
70 | transformTags?: { [tagName: string]: string | Transformer } | undefined;
|
71 | parser?: ParserOptions | undefined;
|
72 | disallowedTagsMode?: DisallowedTagsModes | undefined;
|
73 | /**
|
74 | * Setting this option to true will instruct sanitize-html to discard all characters outside of html tag boundaries
|
75 | * -- before `<html>` and after `</html>` tags
|
76 | * @see {@link https://github.com/apostrophecms/sanitize-html/#discarding-text-outside-of-htmlhtml-tags}
|
77 | * @default true
|
78 | */
|
79 | enforceHtmlBoundary?: boolean | undefined;
|
80 | nonBooleanAttributes?: string[];
|
81 | }
|
82 |
|
83 | const defaults: IDefaults;
|
84 | const options: IOptions;
|
85 |
|
86 | function simpleTransform(tagName: string, attribs: Attributes, merge?: boolean): Transformer;
|
87 | }
|
88 |
|
\ | No newline at end of file |