From: C. Scott Ananian Date: Mon, 18 Jul 2016 20:54:24 +0000 (-0400) Subject: Minor bug fixes to Balancer. X-Git-Tag: 1.31.0-rc.0~6321^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/fiche.php?a=commitdiff_plain;h=5f0505b889b18b5bddd28d01e5b0d89756b46851;p=lhc%2Fweb%2Fwiklou.git Minor bug fixes to Balancer. This is a follow-up to the refactor done in 5726c9ceb0644af360d37b86351b97ddfcbee20c which prevents a crash when the first entry in the stack happens to be a BalanceMarker (and thus doesn't have a `$localName` property). It also fixes an unrelated issue where unpaired close-heading tags (like ``) get entity-escaped instead of ignored. Test cases exposing these bugs are added in Ie854cf99f7e72bcca1bb8565ace558a43dcb6379. Change-Id: Ia9a1d435be1be10512071f5ff626b68742863483 --- diff --git a/includes/tidy/Balancer.php b/includes/tidy/Balancer.php index 9e96b14c60..4bcaf1a064 100644 --- a/includes/tidy/Balancer.php +++ b/includes/tidy/Balancer.php @@ -1613,9 +1613,11 @@ class BalanceActiveFormattingElements { // Loop backward through the list until we find a marker or an // open element + $foundit = false; while ( $entry->prevAFE ) { $entry = $entry->prevAFE; if ( $entry instanceof BalanceMarker || $stack->indexOf( $entry ) >= 0 ) { + $foundit = true; break; } } @@ -1624,7 +1626,7 @@ class BalanceActiveFormattingElements { // the first element if we didn't find a marker or open element), // recreating formatting elements and pushing them back onto the list // of open elements. - if ( $entry->prevAFE ) { + if ( $foundit ) { $entry = $entry->nextAFE; } do { @@ -2656,7 +2658,7 @@ class Balancer { case 'h5': case 'h6': if ( !$this->stack->inScope( BalanceSets::$headingSet ) ) { - return; + return true; # ignore } $this->stack->generateImpliedEndTags(); $this->stack->popTag( BalanceSets::$headingSet );