From 57c7c00d6744a25bd3247f0573ad6bfde6f546f6 Mon Sep 17 00:00:00 2001 From: Giorgio Scalvini Date: Wed, 27 Sep 2023 13:57:48 +0200 Subject: [PATCH 1/2] Modified PHPUnit inclusion to support composer autoloader and drop support for PHP <5.3.3 --- composer.json | 2 +- package.xml | 2 +- tests/HTML_SafeTest.php | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 59ec51e..7d2bb70 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "source": "https://github.com/pear/HTML_Safe" }, "require": { - "php": ">=5.2", + "php": ">=5.3.3", "pear/pear_exception": "*", "pear/xml_htmlsax3": "*" }, diff --git a/package.xml b/package.xml index d122867..9989405 100644 --- a/package.xml +++ b/package.xml @@ -35,7 +35,7 @@ - 5.2 + 5.3.3 1.6 diff --git a/tests/HTML_SafeTest.php b/tests/HTML_SafeTest.php index 0c7743a..288e69b 100644 --- a/tests/HTML_SafeTest.php +++ b/tests/HTML_SafeTest.php @@ -1,6 +1,11 @@ Date: Thu, 28 Sep 2023 08:45:19 +0200 Subject: [PATCH 2/2] Add tests for missing closure tag, missing open tag, paragraph closure, single tag and insecure tag --- tests/HTML_SafeTest.php | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/HTML_SafeTest.php b/tests/HTML_SafeTest.php index 288e69b..514399f 100644 --- a/tests/HTML_SafeTest.php +++ b/tests/HTML_SafeTest.php @@ -34,4 +34,53 @@ public function testSpecialChars() $this->assertSame($expectedOne, $safe->parse($inputOne)); $this->assertSame($expectedTwo, $safe->parse($inputTwo)); } + + public function testMissingClosureTag() + { + $input = '
my text with missing tag closure
'; + $expected = '
my text with missing tag closure
'; + + $safe = new HTML_Safe(); + $this->assertSame($expected, $safe->parse($input)); + } + + public function testMissingOpenTag() + { + $input = '
my text with missing tag opening
'; + $expected = '
my text with missing tag opening
'; + + $safe = new HTML_Safe(); + $this->assertSame($expected, $safe->parse($input)); + } + + public function testParagraphClosure() + { + $input = '

my first title

my text

my second title

'; + $expected = '

my first title

my text

my second title

'; + + $safe = new HTML_Safe(); + $this->assertSame($expected, $safe->parse($input)); + } + + public function testSingleTags() + { + $inputOne = 'Test image'; + $expectedOne = 'Test image'; + + $inputTwo = 'Test imageTEST'; + $expectedTwo = 'Test imageTEST'; + + $safe = new HTML_Safe(); + $this->assertSame($expectedOne, $safe->parse($inputOne)); + $this->assertSame($expectedTwo, $safe->parse($inputTwo)); + } + + public function testInsecureTags() + { + $input = '
Iframe content:
'; + $expected = '
Iframe content:
'; + + $safe = new HTML_Safe(); + $this->assertSame($expected, $safe->parse($input)); + } }