File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ public function filter(string $string): string
120
120
case '> ' === $ char :
121
121
if ($ this ->isIgnoredTag ($ tagName )) {
122
122
$ ignoreTagContent = true ;
123
- } elseif ('/ ' === $ tagName [0 ]) {
123
+ } elseif ($ tagName === null || '/ ' === $ tagName [0 ]) {
124
124
$ ignoreTagContent = false ; // Restore to default state.
125
125
}
126
126
$ context = self ::CTX_TAG_CONTENT ;
@@ -258,6 +258,10 @@ function ($match) {
258
258
*/
259
259
private function isIgnoredTag (?string $ name ): bool
260
260
{
261
+ if ($ name === null ) {
262
+ return false ;
263
+ }
264
+
261
265
foreach (self ::$ ignoreTags as $ tag ) {
262
266
if (strcasecmp ($ tag , $ name ) === 0 ) {
263
267
return true ;
Original file line number Diff line number Diff line change @@ -90,4 +90,12 @@ public function testMalformedAttribute(): void
90
90
$ text = ' test ' ;
91
91
static ::assertEquals ($ text , $ filter ->filter ($ html ));
92
92
}
93
+
94
+ public function testMalformedTags (): void
95
+ {
96
+ $ filter = new HtmlFilter ();
97
+ $ html = "foo/>bar<br><br/> " ;
98
+ $ text = "foo/ bar " ;
99
+ static ::assertEquals ($ text , $ filter ->filter ($ html ));
100
+ }
93
101
}
You can’t perform that action at this time.
0 commit comments