X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/vendor/wikimedia/remex-html/RemexHtml/TreeBuilder/InHeadNoscript.php diff --git a/vendor/wikimedia/remex-html/RemexHtml/TreeBuilder/InHeadNoscript.php b/vendor/wikimedia/remex-html/RemexHtml/TreeBuilder/InHeadNoscript.php new file mode 100644 index 00000000..d2fea3fc --- /dev/null +++ b/vendor/wikimedia/remex-html/RemexHtml/TreeBuilder/InHeadNoscript.php @@ -0,0 +1,97 @@ +builder; + $dispatcher = $this->dispatcher; + + // Insert whitespace + list( $part1, $part2 ) = $this->splitInitialMatch( true, "\t\n\f\r ", + $text, $start, $length, $sourceStart, $sourceLength ); + list( $start, $length, $sourceStart, $sourceLength ) = $part1; + if ( $length ) { + $dispatcher->inHead->characters( + $text, $start, $length, $sourceStart, $sourceLength ); + } + + // Switch mode on non-whitespace + list( $start, $length, $sourceStart, $sourceLength ) = $part2; + if ( $length ) { + $builder->error( "unexpected non-whitespace character in head in noscript, " . + "closing noscript", $sourceStart ); + $builder->pop( $sourceStart, 0 ); + $dispatcher->switchMode( Dispatcher::IN_HEAD ) + ->characters( $text, $start, $length, $sourceStart, $sourceLength ); + } + } + + public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) { + $builder = $this->builder; + $dispatcher = $this->dispatcher; + + switch ( $name ) { + case 'html': + $dispatcher->inBody->startTag( $name, $attrs, $selfClose, $sourceStart, $sourceLength ); + break; + + case 'basefont': + case 'bgsound': + case 'link': + case 'meta': + case 'noframes': + case 'style': + $dispatcher->inHead->startTag( $name, $attrs, $selfClose, $sourceStart, $sourceLength ); + break; + + case 'head': + case 'noscript': + $builder->error( "unexpected <$name> in head in noscript, ignoring", $sourceStart ); + return; + + default: + $builder->error( "unexpected <$name> in head in noscript, closing noscript", + $sourceStart ); + $builder->pop( $sourceStart, 0 ); + $dispatcher->switchMode( Dispatcher::IN_HEAD ) + ->startTag( $name, $attrs, $selfClose, $sourceStart, $sourceLength ); + } + } + + public function endTag( $name, $sourceStart, $sourceLength ) { + $builder = $this->builder; + $dispatcher = $this->dispatcher; + + switch ( $name ) { + case 'noscript': + $builder->pop( $sourceStart, $sourceLength ); + $dispatcher->switchMode( Dispatcher::IN_HEAD ); + break; + + case 'br': + $builder->error( "unexpected
in head in noscript, closing noscript", + $sourceStart ); + $builder->pop( $sourceStart, 0 ); + $dispatcher->switchMode( Dispatcher::IN_HEAD ) + ->endTag( $name, $sourceStart, $sourceLength ); + break; + + default: + $builder->error( "unexpected in head in noscript, ignoring", + $sourceStart ); + return; + } + } + + public function endDocument( $pos ) { + $this->builder->error( "unexpected end-of-file in head in noscript", $pos ); + $this->builder->pop( $pos, 0 ); + $this->dispatcher->switchMode( Dispatcher::IN_HEAD ) + ->endDocument( $pos ); + } +}