X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2Ftidy%2FBalancer.php;h=fa89c1a5e167dcc9ca1ec463d771ba4b757b8a20;hb=3b7f4539639b3899e246e245df481882f81f9340;hp=82c35bb881b1499623ee20351ecf58a1575f2491;hpb=1b13888ed6bd09731f10045650714a3392bb55df;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/tidy/Balancer.php b/includes/tidy/Balancer.php index 82c35bb881..fa89c1a5e1 100644 --- a/includes/tidy/Balancer.php +++ b/includes/tidy/Balancer.php @@ -23,14 +23,15 @@ * @since 1.27 * @author C. Scott Ananian, 2016 */ + namespace MediaWiki\Tidy; +use ExplodeIterator; +use IteratorAggregate; +use ReverseArrayIterator; +use Sanitizer; use Wikimedia\Assert\Assert; use Wikimedia\Assert\ParameterAssertionException; -use \ExplodeIterator; -use \IteratorAggregate; -use \ReverseArrayIterator; -use \Sanitizer; // A note for future librarization[1] -- this file is a good candidate // for splitting into an independent library, except that it is currently @@ -2052,73 +2053,73 @@ class Balancer { return true; } elseif ( $token === 'tag' ) { switch ( $value ) { - case 'font': - if ( isset( $attribs['color'] ) - || isset( $attribs['face'] ) - || isset( $attribs['size'] ) - ) { - break; - } - // otherwise, fall through - case 'b': - case 'big': - case 'blockquote': - case 'body': - case 'br': - case 'center': - case 'code': - case 'dd': - case 'div': - case 'dl': - case 'dt': - case 'em': - case 'embed': - case 'h1': - case 'h2': - case 'h3': - case 'h4': - case 'h5': - case 'h6': - case 'head': - case 'hr': - case 'i': - case 'img': - case 'li': - case 'listing': - case 'menu': - case 'meta': - case 'nobr': - case 'ol': - case 'p': - case 'pre': - case 'ruby': - case 's': - case 'small': - case 'span': - case 'strong': - case 'strike': - case 'sub': - case 'sup': - case 'table': - case 'tt': - case 'u': - case 'ul': - case 'var': - if ( $this->fragmentContext ) { - break; - } - while ( true ) { - $this->stack->pop(); - $node = $this->stack->currentNode; - if ( - $node->isMathmlTextIntegrationPoint() || - $node->isHtmlIntegrationPoint() || - $node->isHtml() + case 'font': + if ( isset( $attribs['color'] ) + || isset( $attribs['face'] ) + || isset( $attribs['size'] ) ) { break; } - } - return $this->insertToken( $token, $value, $attribs, $selfClose ); + // otherwise, fall through + case 'b': + case 'big': + case 'blockquote': + case 'body': + case 'br': + case 'center': + case 'code': + case 'dd': + case 'div': + case 'dl': + case 'dt': + case 'em': + case 'embed': + case 'h1': + case 'h2': + case 'h3': + case 'h4': + case 'h5': + case 'h6': + case 'head': + case 'hr': + case 'i': + case 'img': + case 'li': + case 'listing': + case 'menu': + case 'meta': + case 'nobr': + case 'ol': + case 'p': + case 'pre': + case 'ruby': + case 's': + case 'small': + case 'span': + case 'strong': + case 'strike': + case 'sub': + case 'sup': + case 'table': + case 'tt': + case 'u': + case 'ul': + case 'var': + if ( $this->fragmentContext ) { + break; + } + while ( true ) { + $this->stack->pop(); + $node = $this->stack->currentNode; + if ( + $node->isMathmlTextIntegrationPoint() || + $node->isHtmlIntegrationPoint() || + $node->isHtml() + ) { + break; + } + } + return $this->insertToken( $token, $value, $attribs, $selfClose ); } // "Any other start tag" $adjusted = ( $this->fragmentContext && $this->stack->length() === 1 ) ? @@ -2270,56 +2271,56 @@ class Balancer { } if ( $node->isHtml() ) { switch ( $node->localName ) { - case 'select': - $stackLength = $this->stack->length(); - for ( $j = $i + 1; $j < $stackLength - 1; $j++ ) { - $ancestor = $this->stack->node( $stackLength - $j - 1 ); - if ( $ancestor->isHtmlNamed( 'template' ) ) { - break; - } - if ( $ancestor->isHtmlNamed( 'table' ) ) { - $this->switchMode( 'inSelectInTableMode' ); - return; + case 'select': + $stackLength = $this->stack->length(); + for ( $j = $i + 1; $j < $stackLength - 1; $j++ ) { + $ancestor = $this->stack->node( $stackLength - $j - 1 ); + if ( $ancestor->isHtmlNamed( 'template' ) ) { + break; + } + if ( $ancestor->isHtmlNamed( 'table' ) ) { + $this->switchMode( 'inSelectInTableMode' ); + return; + } } - } - $this->switchMode( 'inSelectMode' ); - return; - case 'tr': - $this->switchMode( 'inRowMode' ); - return; - case 'tbody': - case 'tfoot': - case 'thead': - $this->switchMode( 'inTableBodyMode' ); - return; - case 'caption': - $this->switchMode( 'inCaptionMode' ); - return; - case 'colgroup': - $this->switchMode( 'inColumnGroupMode' ); - return; - case 'table': - $this->switchMode( 'inTableMode' ); - return; - case 'template': - $this->switchMode( - array_slice( $this->templateInsertionModes, -1 )[0] - ); - return; - case 'body': - $this->switchMode( 'inBodyMode' ); - return; - // OMITTED: