From 214cb8a6934f9682ce5a9d7a7f5a76801c7822e6 Mon Sep 17 00:00:00 2001 From: Marcus Artner Date: Tue, 26 Jan 2021 17:11:50 +0100 Subject: [PATCH] Fixed Issue #264: element removed from if there are no or elements (#283) --- library/HTMLPurifier/ChildDef/Table.php | 2 +- tests/HTMLPurifier/ChildDef/TableTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/library/HTMLPurifier/ChildDef/Table.php b/library/HTMLPurifier/ChildDef/Table.php index cb6b3e6c..67c7e953 100644 --- a/library/HTMLPurifier/ChildDef/Table.php +++ b/library/HTMLPurifier/ChildDef/Table.php @@ -164,7 +164,7 @@ class HTMLPurifier_ChildDef_Table extends HTMLPurifier_ChildDef } } - if (empty($content)) { + if (empty($content) && $thead === false && $tfoot === false) { return false; } diff --git a/tests/HTMLPurifier/ChildDef/TableTest.php b/tests/HTMLPurifier/ChildDef/TableTest.php index 49e96b65..aba6b1dc 100644 --- a/tests/HTMLPurifier/ChildDef/TableTest.php +++ b/tests/HTMLPurifier/ChildDef/TableTest.php @@ -44,6 +44,22 @@ class HTMLPurifier_ChildDef_TableTest extends HTMLPurifier_ChildDefHarness ); } + public function testTheadOnlyNotRemoved() + { + $this->assertResult( + '', + '' + ); + } + + public function testTbodyOnlyNotRemoved() + { + $this->assertResult( + '', + '' + ); + } + public function testTrOverflowAndClose() { $this->assertResult(
a
a
a
a