File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 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
120120 case '> ' === $ char :
121121 if ($ this ->isIgnoredTag ($ tagName )) {
122122 $ ignoreTagContent = true ;
123- } elseif ('/ ' === $ tagName [0 ]) {
123+ } elseif ($ tagName === null || '/ ' === $ tagName [0 ]) {
124124 $ ignoreTagContent = false ; // Restore to default state.
125125 }
126126 $ context = self ::CTX_TAG_CONTENT ;
@@ -258,6 +258,10 @@ function ($match) {
258258 */
259259 private function isIgnoredTag (?string $ name ): bool
260260 {
261+ if ($ name === null ) {
262+ return false ;
263+ }
264+
261265 foreach (self ::$ ignoreTags as $ tag ) {
262266 if (strcasecmp ($ tag , $ name ) === 0 ) {
263267 return true ;
Original file line number Diff line number Diff line change @@ -90,4 +90,12 @@ public function testMalformedAttribute(): void
9090 $ text = ' test ' ;
9191 static ::assertEquals ($ text , $ filter ->filter ($ html ));
9292 }
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+ }
93101}
You can’t perform that action at this time.
0 commit comments