Skip to content

Commit

Permalink
fix HTML filter issue when the text contains malformed HTML tags
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierpontier committed Aug 20, 2020
1 parent a358650 commit 629e86d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Source/Filter/HtmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ function ($match) {
*/
private function isIgnoredTag(?string $name): bool
{
if ($name === null) {
return false;
}

foreach (self::$ignoreTags as $tag) {
if (strcasecmp($tag, $name) === 0) {
return true;
Expand Down
8 changes: 8 additions & 0 deletions tests/Unit/Source/Filter/HtmlFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,12 @@ public function testMalformedAttribute(): void
$text = ' test ';
static::assertEquals($text, $filter->filter($html));
}

public function testMalformedTags(): void
{
$filter = new HtmlFilter();
$html = "foo/>bar<br><br/>";
$text = "foo/ bar ";
static::assertEquals($text, $filter->filter($html));
}
}

0 comments on commit 629e86d

Please sign in to comment.