Skip to content

Commit

Permalink
Fix double lt bug (HTMLParser)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauro Cassani committed Jun 8, 2021
1 parent cc3531b commit 8dfdbe8
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/Filters/Html/HtmlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,9 @@ public function transform( $segment ) {

$originalSplit = preg_split( '//u', $segment, -1, PREG_SPLIT_NO_EMPTY );

// $strippedSplit = preg_split( '//u', str_replace( [ "<", ">" ], "", $segment ), -1, PREG_SPLIT_NO_EMPTY );
// if ( $originalSplit == $strippedSplit ) {
// return $segment;
// }

$state = static::STATE_PLAINTEXT;
$html_buffer = '';
$plain_text_buffer = '';
$depth = 0;
$in_quote_char = '';
$output = '';

Expand All @@ -106,8 +100,10 @@ public function transform( $segment ) {
break;
}

// we're seeing a nested '<'
$depth++;
// if we found a second less than symbol the first one IS NOT a tag,
// treat the html_buffer as plain text and attach to the output
$output .= $this->_fixWrongBuffer( $html_buffer );
$html_buffer = $char;
break;

case '>':
Expand All @@ -116,13 +112,6 @@ public function transform( $segment ) {
break;
}

// something like this is happening: '<<>>'
if ( $depth ) {
$depth--;

break;
}

if ( in_array( substr( $html_buffer, 0, 6 ), [ '<scrip', '<style' ] ) ) {
$html_buffer .= $char;
$state = static::STATE_JS_CSS;
Expand Down Expand Up @@ -234,4 +223,4 @@ public function transform( $segment ) {

}

}
}

0 comments on commit 8dfdbe8

Please sign in to comment.