Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Tests/OutputFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ public function testStripImages()
$this->object->stripImages('Hello <<img>img src="wave.jpg"> I am waving at you.'),
'Should remove nested img tags'
);

$this->assertEquals(
'Hello I am waving at you.',
$this->object->stripImages("Hello <img\nsrc=\"wave.jpg\" onerror=\"alert(1)\"> I am waving at you."),
'Should remove img tags containing newlines'
);
}

/**
Expand Down Expand Up @@ -260,6 +266,12 @@ public function testStripIframes()
),
'Should remove nested iFrame tags'
);

$this->assertEquals(
'Hello I am waving at you.',
$this->object->stripIframes("Hello <iframe\nsrc=\"http://player.vimeo.com/video/37576499\"></iframe> I am waving at you."),
'Should remove iFrame tags containing newlines'
);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/OutputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ public static function setLanguage(Language $language): void
*/
public static function stripImages($string)
{
while (preg_match('#(<[/]?img.*>)#Ui', $string)) {
$string = preg_replace('#(<[/]?img.*>)#Ui', '', $string);
while (preg_match('#(<[/]?img.*>)#Uis', $string)) {
$string = preg_replace('#(<[/]?img.*>)#Uis', '', $string);
}

return $string;
Expand All @@ -281,8 +281,8 @@ public static function stripImages($string)
*/
public static function stripIframes($string)
{
while (preg_match('#(<[/]?iframe.*>)#Ui', $string)) {
$string = preg_replace('#(<[/]?iframe.*>)#Ui', '', $string);
while (preg_match('#(<[/]?iframe.*>)#Uis', $string)) {
$string = preg_replace('#(<[/]?iframe.*>)#Uis', '', $string);
}

return $string;
Expand Down
Loading