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