From 87bbf69ce8f673c022b6db55be232ecdf2cb343a Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 19 Aug 2020 21:02:55 -0700 Subject: [PATCH] Revert "fix(core): remove closing body tag from inert DOM builder (#38454)" This reverts commit 552853648ca75fe420ba594ba48555da39f263c7. --- packages/core/src/sanitization/inert_body.ts | 5 ++--- .../test/sanitization/html_sanitizer_spec.ts | 21 ------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/packages/core/src/sanitization/inert_body.ts b/packages/core/src/sanitization/inert_body.ts index 0d7173f01a..62c6598df8 100644 --- a/packages/core/src/sanitization/inert_body.ts +++ b/packages/core/src/sanitization/inert_body.ts @@ -32,9 +32,8 @@ class DOMParserHelper implements InertBodyHelper { getInertBodyElement(html: string): HTMLElement|null { // We add these extra elements to ensure that the rest of the content is parsed as expected // e.g. leading whitespace is maintained and tags like `` do not get hoisted to the - // `` tag. Note that the `` tag is closed implicitly to prevent unclosed tags - // in `html` from consuming the otherwise explicit `` tag. - html = '' + html; + // `` tag. + html = '' + html + ''; try { const body = new (window as any).DOMParser().parseFromString(html, 'text/html').body as HTMLBodyElement; diff --git a/packages/core/test/sanitization/html_sanitizer_spec.ts b/packages/core/test/sanitization/html_sanitizer_spec.ts index d577ce2c4d..dc83ca31f5 100644 --- a/packages/core/test/sanitization/html_sanitizer_spec.ts +++ b/packages/core/test/sanitization/html_sanitizer_spec.ts @@ -173,27 +173,6 @@ import {isDOMParserAvailable} from '../../src/sanitization/inert_body'; expect(logMsgs.join('\n')).toMatch(/sanitizing HTML stripped some content/); }); - it('should strip unclosed iframe tag', () => { - expect(_sanitizeHtml(defaultDoc, '