From 8abc1fade539a6425db6eecbfc15c152faeabac6 Mon Sep 17 00:00:00 2001 From: Will Gibson Date: Wed, 29 Aug 2018 15:06:33 +0100 Subject: [PATCH 1/2] Add parser to sanitize-html's IOptions interface --- types/sanitize-html/index.d.ts | 2 ++ types/sanitize-html/sanitize-html-tests.ts | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/types/sanitize-html/index.d.ts b/types/sanitize-html/index.d.ts index 2e7527e3fc..8ec8e05901 100644 --- a/types/sanitize-html/index.d.ts +++ b/types/sanitize-html/index.d.ts @@ -4,6 +4,7 @@ // Afshin Darian // BehindTheMath // Rinze de Laat +// Will Gibson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = sanitize; @@ -51,6 +52,7 @@ declare namespace sanitize { nonTextTags?: string[]; selfClosing?: string[]; transformTags?: { [tagName: string]: string | Transformer }; + parser: {}; } diff --git a/types/sanitize-html/sanitize-html-tests.ts b/types/sanitize-html/sanitize-html-tests.ts index b02a5a6653..51d03bf3fe 100644 --- a/types/sanitize-html/sanitize-html-tests.ts +++ b/types/sanitize-html/sanitize-html-tests.ts @@ -29,7 +29,10 @@ let options: sanitize.IOptions = { allowedSchemesByTag: { 'a': ['http', 'https'] }, - allowProtocolRelative: false + allowProtocolRelative: false, + parser: { + decodeEntities: true + } }; let unsafe = '
'; From 2dd8b42fd965d23d969e2382f12fd9d87db2cc8c Mon Sep 17 00:00:00 2001 From: Will Gibson Date: Thu, 30 Aug 2018 10:34:29 +0100 Subject: [PATCH 2/2] Use htmlparser2's Options --- types/sanitize-html/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/sanitize-html/index.d.ts b/types/sanitize-html/index.d.ts index 8ec8e05901..88959fa0c6 100644 --- a/types/sanitize-html/index.d.ts +++ b/types/sanitize-html/index.d.ts @@ -7,6 +7,8 @@ // Will Gibson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import {Options} from "htmlparser2"; + export = sanitize; declare function sanitize(dirty: string, options?: sanitize.IOptions): string; @@ -52,7 +54,7 @@ declare namespace sanitize { nonTextTags?: string[]; selfClosing?: string[]; transformTags?: { [tagName: string]: string | Transformer }; - parser: {}; + parser: Options; }