Merge "Treat langtags in SVG switch case-insensitively"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 15 Nov 2017 10:17:32 +0000 (10:17 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 15 Nov 2017 10:17:32 +0000 (10:17 +0000)
1  2 
includes/filerepo/file/File.php
includes/page/ImagePage.php
tests/parser/parserTests.txt

@@@ -581,6 -581,25 +581,25 @@@ abstract class File implements IDBAcces
                }
        }
  
+       /**
+        * Get the language code from the available languages for this file that matches the language
+        * requested by the user
+        *
+        * @param string $userPreferredLanguage
+        * @return string|null
+        */
+       public function getMatchedLanguage( $userPreferredLanguage ) {
+               $handler = $this->getHandler();
+               if ( $handler && method_exists( $handler, 'getMatchedLanguage' ) ) {
+                       return $handler->getMatchedLanguage(
+                               $userPreferredLanguage,
+                               $handler->getAvailableLanguages( $this )
+                       );
+               } else {
+                       return null;
+               }
+       }
        /**
         * In files that support multiple language, what is the default language
         * to use if none specified.
                // Purge cache of all pages using this file
                $title = $this->getTitle();
                if ( $title ) {
 -                      DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) );
 +                      DeferredUpdates::addUpdate(
 +                              new HTMLCacheUpdate( $title, 'imagelinks', 'file-purge' )
 +                      );
                }
        }
  
@@@ -285,6 -285,19 +285,19 @@@ class ImagePage extends Article 
                return parent::getContentObject();
        }
  
+       private function getLanguageForRendering( WebRequest $request, File $file ) {
+               $handler = $this->displayImg->getHandler();
+               $requestLanguage = $request->getVal( 'lang' );
+               if ( !is_null( $requestLanguage ) ) {
+                       if ( $handler && $handler->validateParam( 'lang', $requestLanguage ) ) {
+                               return $requestLanguage;
+                       }
+               }
+               return $handler->getDefaultRenderLanguage( $this->displayImg );
+       }
        protected function openShowImage() {
                global $wgEnableUploads, $wgSend404Code, $wgSVGMaxSize;
  
                                $params = [ 'page' => $page ];
                        }
  
-                       $renderLang = $request->getVal( 'lang' );
+                       $renderLang = $this->getLanguageForRendering( $request, $this->displayImg );
                        if ( !is_null( $renderLang ) ) {
-                               $handler = $this->displayImg->getHandler();
-                               if ( $handler && $handler->validateParam( 'lang', $renderLang ) ) {
-                                       $params['lang'] = $renderLang;
-                               } else {
-                                       $renderLang = null;
-                               }
+                               $params['lang'] = $renderLang;
                        }
  
                        $width_orig = $this->displayImg->getWidth( $page );
@@@ -544,12 -552,7 +552,7 @@@ EO
  
                        $renderLangOptions = $this->displayImg->getAvailableLanguages();
                        if ( count( $renderLangOptions ) >= 1 ) {
-                               $currentLanguage = $renderLang;
-                               $defaultLang = $this->displayImg->getDefaultRenderLanguage();
-                               if ( is_null( $currentLanguage ) ) {
-                                       $currentLanguage = $defaultLang;
-                               }
-                               $out->addHTML( $this->doRenderLangOpt( $renderLangOptions, $currentLanguage, $defaultLang ) );
+                               $out->addHTML( $this->doRenderLangOpt( $renderLangOptions, $renderLang ) );
                        }
  
                        // Add cannot animate thumbnail warning
@@@ -963,7 -966,7 +966,7 @@@ EO
                                $fromSrc = $this->getContext()->msg(
                                        'shared-repo-from',
                                        $file->getRepo()->getDisplayName()
 -                              )->text();
 +                              )->escaped();
                        }
                        $out->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
                }
         * Output a drop-down box for language options for the file
         *
         * @param array $langChoices Array of string language codes
-        * @param string $curLang Language code file is being viewed in.
-        * @param string $defaultLang Language code that image is rendered in by default
+        * @param string $renderLang Language code for the language we want the file to rendered in.
         * @return string HTML to insert underneath image.
         */
-       protected function doRenderLangOpt( array $langChoices, $curLang, $defaultLang ) {
+       protected function doRenderLangOpt( array $langChoices, $renderLang ) {
                global $wgScript;
-               sort( $langChoices );
-               $curLang = LanguageCode::bcp47( $curLang );
-               $defaultLang = LanguageCode::bcp47( $defaultLang );
                $opts = '';
-               $haveCurrentLang = false;
-               $haveDefaultLang = false;
-               // We make a list of all the language choices in the file.
-               // Additionally if the default language to render this file
-               // is not included as being in this file (for example, in svgs
-               // usually the fallback content is the english content) also
-               // include a choice for that. Last of all, if we're viewing
-               // the file in a language not on the list, add it as a choice.
+               $matchedRenderLang = $this->displayImg->getMatchedLanguage( $renderLang );
                foreach ( $langChoices as $lang ) {
-                       $code = LanguageCode::bcp47( $lang );
-                       $name = Language::fetchLanguageName( $code, $this->getContext()->getLanguage()->getCode() );
-                       if ( $name !== '' ) {
-                               $display = $this->getContext()->msg( 'img-lang-opt', $code, $name )->text();
-                       } else {
-                               $display = $code;
-                       }
-                       $opts .= "\n" . Xml::option( $display, $code, $curLang === $code );
-                       if ( $curLang === $code ) {
-                               $haveCurrentLang = true;
-                       }
-                       if ( $defaultLang === $code ) {
-                               $haveDefaultLang = true;
-                       }
-               }
-               if ( !$haveDefaultLang ) {
-                       // Its hard to know if the content is really in the default language, or
-                       // if its just unmarked content that could be in any language.
-                       $opts = Xml::option(
-                                       $this->getContext()->msg( 'img-lang-default' )->text(),
-                               $defaultLang,
-                               $defaultLang === $curLang
-                       ) . $opts;
-               }
-               if ( !$haveCurrentLang && $defaultLang !== $curLang ) {
-                       $name = Language::fetchLanguageName( $curLang, $this->getContext()->getLanguage()->getCode() );
-                       if ( $name !== '' ) {
-                               $display = $this->getContext()->msg( 'img-lang-opt', $curLang, $name )->text();
-                       } else {
-                               $display = $curLang;
-                       }
-                       $opts = Xml::option( $display, $curLang, true ) . $opts;
+                       $opts .= $this->createXmlOptionStringForLanguage(
+                               $lang,
+                               $matchedRenderLang === $lang
+                       );
                }
  
+               // Allow for the default case in an svg <switch> that is displayed if no
+               // systemLanguage attribute matches
+               $opts .= "\n" .
+                       Xml::option(
+                               $this->getContext()->msg( 'img-lang-default' )->text(),
+                               'und',
+                               is_null( $matchedRenderLang )
+                       );
                $select = Html::rawElement(
                        'select',
                        [ 'id' => 'mw-imglangselector', 'name' => 'lang' ],
                return $langSelectLine;
        }
  
+       /**
+        * @param $lang string
+        * @param $selected bool
+        * @return string
+        */
+       private function createXmlOptionStringForLanguage( $lang, $selected ) {
+               $code = LanguageCode::bcp47( $lang );
+               $name = Language::fetchLanguageName( $code, $this->getContext()->getLanguage()->getCode() );
+               if ( $name !== '' ) {
+                       $display = $this->getContext()->msg( 'img-lang-opt', $code, $name )->text();
+               } else {
+                       $display = $code;
+               }
+               return "\n" .
+                       Xml::option(
+                               $display,
+                               $lang,
+                               $selected
+                       );
+       }
        /**
         * Get the width and height to display image at.
         *
@@@ -1912,33 -1912,6 +1912,33 @@@ a <div>foo</div
  <p>b</p>
  !! end
  
 +!! test
 +No p-wrappable content
 +!! wikitext
 +<span><div>x</div></span>
 +<span><s><div>x</div></s></span>
 +<small><em></em></small><span><s><div>x</div></s></span>
 +!! html+tidy
 +<div><span>x</span></div>
 +<div><span><s>x</s></span></div>
 +<div><span><s>x</s></span></div>
 +!! html/parsoid
 +<span><div>x</div></span>
 +<span><s><div>x</div></s></span>
 +<small><em></em></small><span><s><div>x</div></s></span>
 +!! end
 +
 +# T177612: Parsoid-only test
 +!! test
 +Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
 +!! wikitext
 +{{echo|<span><div>x</div></span>}}
 +x
 +!! html/parsoid
 +<span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;span>&lt;div>x&lt;/div>&lt;/span>"}},"i":0}}]}'><div>x</div></span>
 +<p>x</p>
 +!! end
 +
  !! test
  Block tag on one line (<blockquote>)
  !! wikitext
@@@ -4833,11 -4806,8 +4833,11 @@@ foo//example.com/Fo
  </p>
  !! end
  
 +## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
  !! test
  External links: with no contents
 +!! options
 +parsoid=wt2html,wt2wt
  !! wikitext
  [http://en.wikipedia.org/wiki/Foo]
  
@@@ -4941,7 -4911,7 +4941,7 @@@ External links: Free with trailing quot
  news:'a'b''c''d e
  !! html/php
  <p><b>News:</b> Stuff here
 -</p><p><a rel="nofollow" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e
 +</p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
  </p>
  !! html/parsoid
  <p><b>News:</b> Stuff here</p>
@@@ -5587,8 -5557,8 +5587,8 @@@ External link containing a single quote
  
  [//foo.org/bar'baz bang]
  !! html/php
 -<p><a rel="nofollow" class="external autonumber" href="//foo.org/bar'baz">[1]</a>
 -</p><p><a rel="nofollow" class="external text" href="//foo.org/bar'baz">bang</a>
 +<p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
 +</p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
  </p>
  !! html/parsoid
  <p><a rel="mw:ExtLink" href="//foo.org/bar'baz"></a></p>
@@@ -5706,7 -5676,7 +5706,7 @@@ Examples from RFC 2732, section 2
  
  !! html/php
  <p><a rel="nofollow" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a>
 -</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
 +</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
  </p>
  <ul><li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
  <li> <a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
  <li> <a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
  <li> <a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
  <li> <a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
 -<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
 +<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
  </p>
  <ul><li> <a rel="nofollow" class="external free" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
  <li> <a rel="nofollow" class="external free" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
  !! html/parsoid
  <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a></p>
  
 -<p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
 +<p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
  <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
  <li> <a rel="mw:ExtLink" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
  
 -<p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
 +<p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
  <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
  <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
  <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
@@@ -5769,7 -5739,7 +5769,7 @@@ Examples from RFC 2732, section 2
  
  !! html/php
  <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
 -</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
 +</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
  </p>
  <ul><li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
  <li> <a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
  <li> <a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
  <li> <a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
  <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
 -<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
 +<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
  </p>
  <ul><li> <a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
  <li> <a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
  !! html/parsoid
  <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
  
 -<p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
 +<p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
  <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]">unicast</a></li>
  <li> <a rel="mw:ExtLink" href="http://[FF01::101]">multicast</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::1]/">loopback</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]">ipv4compat</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
  
 -<p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
 +<p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
  <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
  <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
  <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
@@@ -5965,11 -5935,11 +5965,11 @@@ parsoid=html2w
  !! wikitext
  [[Foo|Bar]]
  [[Foo|Bar]]
 -[[wikipedia:Foo|Bar]]
 -[[wikipedia:Foo|Bar]]
 +[[:en:Foo|Bar]]
 +[[:en:Foo|Bar]]
  
 -[[wikipedia:European_Robin|European Robin]]
 -[[wikipedia:European_Robin|European Robin]]
 +[[:en:European_Robin|European Robin]]
 +[[:en:European_Robin|European Robin]]
  !! end
  
  !! test
@@@ -8003,7 -7973,7 +8003,7 @@@ Link containing double-single-quotes '
  !! wikitext
  [[Lista d''e paise d''o munno]]
  !! html/php
 -<p><a href="/index.php?title=Lista_d%27%27e_paise_d%27%27o_munno&amp;action=edit&amp;redlink=1" class="new" title="Lista d''e paise d''o munno (page does not exist)">Lista d''e paise d''o munno</a>
 +<p><a href="/index.php?title=Lista_d%27%27e_paise_d%27%27o_munno&amp;action=edit&amp;redlink=1" class="new" title="Lista d&#39;&#39;e paise d&#39;&#39;o munno (page does not exist)">Lista d''e paise d''o munno</a>
  </p>
  !! html/parsoid
  <p><a rel="mw:WikiLink" href="./Lista_d''e_paise_d''o_munno" title="Lista d''e paise d''o munno">Lista d''e paise d''o munno</a></p>
@@@ -8068,9 -8038,9 +8068,9 @@@ Link with double quotes in title part (
  [[''Pentecoste''|''Pentecoste'']]
  !! html/php
  <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Denys_Savchenko_%27%27Pentecoste%27%27.jpg" class="new" title="File:Denys Savchenko &#39;&#39;Pentecoste&#39;&#39;.jpg">File:Denys Savchenko <i>Pentecoste</i>.jpg</a>
 -</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)">''Pentecoste''</a>
 -</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)">Pentecoste</a>
 -</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)"><i>Pentecoste</i></a>
 +</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)">''Pentecoste''</a>
 +</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)">Pentecoste</a>
 +</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)"><i>Pentecoste</i></a>
  </p>
  !! html/parsoid
  <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Denys_Savchenko_''Pentecoste''.jpg"><img resource="./File:Denys_Savchenko_''Pentecoste''.jpg" src="./Special:FilePath/Denys_Savchenko_''Pentecoste''.jpg" height="220" width="220"/></a></span></p>
@@@ -8363,7 -8333,7 +8363,7 @@@ language=ka
  !! wikitext
  [[Something]]'nice
  !! html
 -<p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (bet ele jaratılmag'an)">Something'nice</a>
 +<p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (bet ele jaratılmag&#39;an)">Something'nice</a>
  </p>
  !! end
  
@@@ -8547,31 -8517,6 +8547,31 @@@ parsoid=html2wt,html2htm
  Aðrir mótmælenda<nowiki/>[[söfnuður]]
  !! end
  
 +!! test
 +Parsoid link bracket escaping
 +!! options
 +parsoid=html2wt,html2html
 +!! html/parsoid
 +<p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
 +<p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
 +<p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
 +<p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
 +<p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
 +<p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
 +!! wikitext
 +[[Test]]
 +
 +[<nowiki/>[[Test]]]
 +
 +[[[[Test]]]]
 +
 +[[[<nowiki/>[[Test]]]]]
 +
 +[[[[[[Test]]]]]]
 +
 +[[[[[<nowiki/>[[Test]]]]]]]
 +!! end
 +
  !! test
  Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
  !! wikitext
@@@ -8639,11 -8584,8 +8639,11 @@@ parsoid=wt2html,wt2wt,html2htm
  <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
  !! end
  
 +## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
  !! test
  Interwiki link encoding conversion (T3636)
 +!! options
 +parsoid=wt2html,wt2wt
  !! wikitext
  *[[Wikipedia:ro:Olteni&#0355;a]]
  *[[Wikipedia:ro:Olteni&#355;a]]
  <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
  <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
  </ul>
 +!! html/parsoid
 +<ul>
 +<li><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
 +<li><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
 +</ul>
  !! end
  
  !! test
@@@ -9474,7 -9411,7 +9474,7 @@@ Handling html with a div self-closing t
  !! html/parsoid
  <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
  <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
 -<div title="" data-parsoid='{"stx":"html","selfClose":true,"brokenHTMLTag":true}'></div>
 +<div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
  <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
  <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
  <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
@@@ -10998,10 -10935,10 +10998,10 @@@ Magic links: RFC (T2479
  !! wikitext
  RFC 822
  !! html/php
 -<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
 +<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
  </p>
  !! html/parsoid
 -<p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
 +<p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
  !! end
  
  !! test
@@@ -11009,10 -10946,10 +11009,10 @@@ Magic links: RFC (T67278
  !! wikitext
  This is RFC 822 but thisRFC 822 is not RFC 822linked.
  !! html/php
 -<p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked.
 +<p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked.
  </p>
  !! html/parsoid
 -<p>This is <a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
 +<p>This is <a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
  !! end
  
  !! test
@@@ -11022,12 -10959,12 +11022,12 @@@ RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 82
  RFC
  822
  !! html/php
 -<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
 +<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
  RFC
  822
  </p>
  !! html/parsoid
 -<p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 822</a>
 +<p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 822</a>
  RFC
  822</p>
  !! end
@@@ -11123,14 -11060,14 +11123,14 @@@ Magic links: use appropriate serializat
  !! wikitext
  X[[Special:BookSources/0978739256|foo]]
  
 -X[//tools.ietf.org/html/rfc1234 foo]
 +X[https://tools.ietf.org/html/rfc1234 foo]
  !! html/php
  <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
 -</p><p>X<a rel="nofollow" class="external text" href="//tools.ietf.org/html/rfc1234">foo</a>
 +</p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
  </p>
  !! html/parsoid
  <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
 -<p>X<a rel="mw:ExtLink" href="//tools.ietf.org/html/rfc1234">foo</a></p>
 +<p>X<a rel="mw:ExtLink" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
  !! end
  
  !! test
@@@ -11387,15 -11324,6 +11387,15 @@@ Templates with templated nam
  <ul about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"{{echo|inner list}} ","href":"./Template:Inner_list"},"params":{},"i":0}}]}'><li> item 1</li></ul>
  !! end
  
 +## Regression test; the output here isn't really that interesting.
 +!! test
 +Templates with templated name and top level template args
 +!! wikitext
 +{{1{{2{{{3}}}|4=5}}}}
 +!! html/parsoid
 +<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1{{2{{{3}}}|4=5}}"},"params":{},"i":0}}]}'>{{1{{2{{{3}}}|4=5}}}}</p>
 +!! end
 +
  # Parsoid markup is deliberate "broken". This is an edge case.
  # See long comment in TemplateHandler.js:convertAttribsToString.
  !! test
@@@ -14834,28 -14762,6 +14834,28 @@@ Alt image option should handle most kin
  <figure class="mw-default-size" typeof="mw:Image/Thumb mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"This is the image caption"},{"ck":"alt","ak":"alt=This is a [[link]] and a {{echo|&#39;&#39;bold template&#39;&#39;}}."}]}' data-mw='{"attribs":[["thumbnail",{"html":"thumb"}],["alt",{"html":"alt=This is a &lt;a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[65,73,2,2]}&#39;>link&lt;/a> and a &lt;i about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"dsr\":[80,106,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;#39;&amp;#39;bold template&amp;#39;&amp;#39;\"}},\"i\":0}}]}&#39;>bold template&lt;/i>."}]]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img alt="This is a link and a bold template." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"alt":"This is a link and a bold template.","resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"alt":"alt=This is a [[link]] and a {{echo|&#39;&#39;bold template&#39;&#39;}}.","resource":"Image:Foobar.jpg"}}'/></a><figcaption>This is the image caption</figcaption></figure>
  !! end
  
 +!! test
 +Image with nested tables in caption
 +!! wikitext
 +[[File:Foobar.jpg|thumb|Foo<br />
 +{|
 +|
 +{|
 +|z
 +|}
 +|}
 +]]
 +!! html/parsoid
 +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Foo&lt;br/>\n{|\n|\n{|\n|z\n|}\n|}\n"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption data-parsoid='{"dsr":[null,50,null,null]}'>Foo<br data-parsoid='{"stx":"html","selfClose":true}'/>
 +<table>
 +<tbody><tr><td>
 +<table>
 +<tbody><tr><td>z</td></tr>
 +</tbody></table></td></tr>
 +</tbody></table>
 +</figcaption></figure>
 +!! end
 +
  ###################
  # Conflicting image format options.
  # First option specified should 'win'.
@@@ -15140,9 -15046,9 +15140,9 @@@ SVG thumbnails with invalid language co
  !! options
  parsoid=wt2html,wt2wt,html2html
  !! wikitext
- [[File:Foobar.svg|thumb|caption|lang=invalid.language.code]]
+ [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
  !! html/php
- <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>lang=invalid.language.code</div></div></div>
+ <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>lang=invalid:language:code</div></div></div>
  
  !! html/parsoid
  <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>lang=invalid.language.code</figcaption></figure>
@@@ -15164,10 -15070,10 +15164,10 @@@ T3887: A RFC with a thumbnai
  !! wikitext
  [[File:Foobar.jpg|thumb|This is RFC 12354]]
  !! html/php
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
  
  !! html/parsoid
 -<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is <a href="//tools.ietf.org/html/rfc12354" rel="mw:ExtLink">RFC 12354</a></figcaption></figure>
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is <a href="https://tools.ietf.org/html/rfc12354" rel="mw:ExtLink">RFC 12354</a></figcaption></figure>
  !! end
  
  !! test
@@@ -15709,9 -15615,9 +15709,9 @@@ T93580: 2. <ref> inside inline image
  
  <references />
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-1\"},\"attrs\":{}}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>&lt;meta typeof=\"mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=&#39;{\"group\":\"\",\"name\":\"\",\"content\":\"foo\",\"hasRefInRef\":false,\"dsr\":[64,78,5,6]}&#39;/>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
 +<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-1\"},\"attrs\":{}}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
  
 -<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
 +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
  !! end
  
  !! test
@@@ -15721,9 -15627,9 +15721,9 @@@ T93580: 3. Templated <ref> inside inlin
  
  <references />
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: {{echo|&lt;ref>{{echo|foo}}&lt;/ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion  mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>&lt;meta typeof=\"mw:Transclusion mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=&#39;{\"group\":\"\",\"name\":\"\",\"content\":\"foo\",\"hasRefInRef\":false,\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;/>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
 +<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: {{echo|&lt;ref>{{echo|foo}}&lt;/ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion  mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
  
 -<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
 +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
  !! end
  
  ###
@@@ -15911,7 -15817,7 +15911,7 @@@ Link to categor
  !! wikitext
  [[:Category:MediaWiki User's Guide]]
  !! html
 -<p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
 +<p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
  </p>
  !! end
  
@@@ -16888,7 -16794,7 +16888,7 @@@ section 
  <h2><span class="mw-headline" id="text_.26_text">text &amp; text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: text &amp; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
  <p>section 3
  </p>
 -<h2><span class="mw-headline" id="text_.27_text">text ' text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: text ' text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span class="mw-headline" id="text_.27_text">text ' text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: text &#039; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
  <p>section 4
  </p>
  <h2><span class="mw-headline" id="text_.22_text">text " text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: text &quot; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
@@@ -18366,16 -18272,18 +18366,16 @@@ Nested template call
  ### Sanitizer
  ###
  
 -# HTML+Tidy effectively strips out the empty tags completely
 -# But since Parsoid doesn't it wraps the <s></s> tags in p-tags
 -# which Tidy would have done for the PHP parser had there been content inside it.
 +# HTML+Tidy strips out empty tags completely. Parsoid doesn't.
 +# FIXME: Wikitext for this first test doesn't match its title.
  !! test
  Sanitizer: Closing of open tags
  !! wikitext
  <s></s><table></table>
 -!! html
 -<s></s><table></table>
 +!! html/php+tidy
  
  !! html/parsoid
 -<p><s></s></p><table></table>
 +<s></s><table></table>
  !! end
  
  !! test
@@@ -18505,20 -18413,6 +18505,20 @@@ all additional text is vanishe
  <p>all additional text is vanished</p>
  !! end
  
 +!! test
 +Language converter glossary rules inside attributes (T119158)
 +!! options
 +language=sr variant=sr-el
 +!! wikitext
 +-{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
 +
 +[[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
 +!! html
 +<p>
 +</p><p><a href="/wiki/%D0%94%D0%B0%D1%82%D0%BE%D1%82%D0%B5%D0%BA%D0%B0:Foobar.jpg" class="image"><img alt="&quot; onload=&quot;alert(1)&quot; data-foo=&quot;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 +</p>
 +!! end
 +
  !! test
  Self closed html pairs (T7487)
  !! wikitext
@@@ -20099,7 -19993,7 +20099,7 @@@ parsoid=wt2htm
  '''''
  !! html/php
  !! html/parsoid
 -<p><b><i></i></b></p>
 +<b><i></i></b>
  !! end
  
  # same html as previous, but wikitext adjusted to match parsoid html2wt
@@@ -20992,7 -20886,7 +20992,7 @@@ Double RF
  !! wikitext
  RFC RFC 1234
  !! html
 -<p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a>
 +<p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
  </p>
  !! end
  
@@@ -21010,10 -20904,10 +21010,10 @@@ RFC code coverag
  !! wikitext
  RFC   983&#x20;987
  !! html
 -<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
 +<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
  </p>
  !! html+tidy
 -<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
 +<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
  !! end
  
  !! test
@@@ -22404,7 -22298,7 +22404,7 @@@ parsoid=
  |}
  !! end
  
 -# Tests LanguageVariantText._fromSelser
 +# Tests LanguageVariantText._fromSelSer
  !! test
  LanguageConverter selser (4)
  !! options
@@@ -22778,21 -22672,6 +22778,21 @@@ a:b=>c xy
  </p>
  !! end
  
 +!! test
 +T179579: Nowiki and lc interaction
 +!! options
 +parsoid=wt2html
 +language=sr
 +!! wikitext
 +-{</nowiki>123}-
 +
 +-{123<nowiki>|</nowiki>456}-
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
 +
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"123&lt;span typeof=\"mw:Nowiki\" data-parsoid=&#39;{\"dsr\":[23,41,8,9]}&#39;>|&lt;/span>456"}}' data-parsoid='{"fl":[],"src":"-{123&lt;nowiki>|&lt;/nowiki>456}-"}'></span></p>
 +!! end
 +
  !! test
  T2529: Uncovered bullet
  !! wikitext
@@@ -24569,7 -24448,9 +24569,7 @@@ parsoid=wt2html,wt2w
  !! wikitext
  '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
  !! html/parsoid
 -<p><b><small></small></b></p>
 -<figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure>
 -<p></p>
 +<b><small><figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure></small></b>
  !! end
  
  #### ----------------------------------------------------------------
@@@ -25768,9 -25649,9 +25768,9 @@@ Links 8. Add <nowiki/>s between text-no
  !! options
  parsoid=html2wt
  !! html/parsoid
 -<p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
 -<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
 -X<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
 +<p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
 +<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
 +X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
  !! wikitext
  RFC 123<nowiki/>4
  RFC 123<nowiki/>y
@@@ -25782,18 -25663,18 +25782,18 @@@ Links 9. Don't add spurious <nowiki/>s 
  !! options
  parsoid=html2wt
  !! html/parsoid
 -<p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
 -<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
 --<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
 +<p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
 +<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
 +-<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
  </p>
  !! wikitext
  RFC 123?foo
  RFC 123&foo
  -RFC 123-
  !! html/php
 -<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>?foo
 -<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
 --<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>-
 +<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
 +<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
 +-<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
  </p>
  !! end
  
@@@ -28054,9 -27935,9 +28054,9 @@@ Edited RFC links not serializable as RF
  !! options
  parsoid=html2wt
  !! html/parsoid
 -<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
 +<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
  !! wikitext
 -[//tools.ietf.org/html/rfc123 New RFC]
 +[https://tools.ietf.org/html/rfc123 New RFC]
  !! end
  
  !! test
@@@ -28200,7 -28081,7 +28200,7 @@@ Magic links inside image captions (auto
  <div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
  <div class="thumbcaption">
  <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
 -<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a></div>
 +<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a></div>
  </div>
  </div>
  <div class="thumb tright">
  </div>
  !! html/parsoid
  <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></figcaption></figure>
 -<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//tools.ietf.org/html/rfc1234" rel="mw:ExtLink">RFC 1234</a></figcaption></figure>
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink">RFC 1234</a></figcaption></figure>
  <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></figcaption></figure>
  <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="./Special:BookSources/123456789X" rel="mw:WikiLink">ISBN 123456789x</a></figcaption></figure>
  !! end
@@@ -29546,7 -29427,7 +29546,7 @@@ wgFragmentMode=[ 'html5', 'legacy' 
  <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
  <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
  <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
 -<li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_'"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
 +<li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
  </ul>
  </div>
  
  <h2><span id=".D0.A2.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="Тест">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
  <h2><span id=".D0.A2.D0.B5.D1.81.D1.82_2"></span><span class="mw-headline" id="Тест_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
  <h2><span id=".D1.82.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="тест">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 -<h2><span id="Hey_.3C_.23_.22_.3E_.25_:_.27"></span><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 -<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_'">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
 +<h2><span id="Hey_.3C_.23_.22_.3E_.25_:_.27"></span><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
  </p><p>💩 <span id="💩"></span>
  </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
  </p>
@@@ -29602,7 -29483,7 +29602,7 @@@ wgFragmentMode=[ 'legacy', 'html5' 
  <h2><span id="Тест"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
  <h2><span id="Тест_2"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
  <h2><span id="тест"></span><span class="mw-headline" id=".D1.82.D0.B5.D1.81.D1.82">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 -<h2><span id="Hey_&lt;_#_&quot;_&gt;_%_:_'"></span><span class="mw-headline" id="Hey_.3C_.23_.22_.3E_.25_:_.27">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span id="Hey_&lt;_#_&quot;_&gt;_%_:_'"></span><span class="mw-headline" id="Hey_.3C_.23_.22_.3E_.25_:_.27">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
  <p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#.D0.A2.D0.B5.D1.81.D1.82">#Тест</a> <a href="#.D1.82.D0.B5.D1.81.D1.82">#тест</a> <a href="#Hey_.3C_.23_.22_.3E_.25_:_.27">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
  </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
  </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
@@@ -29640,7 -29521,7 +29640,7 @@@ wgFragmentMode=[ 'html5' 
  <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
  <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
  <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
 -<li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_'"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
 +<li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
  </ul>
  </div>
  
  <h2><span class="mw-headline" id="Тест">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
  <h2><span class="mw-headline" id="Тест_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
  <h2><span class="mw-headline" id="тест">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 -<h2><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 -<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_'">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
 +<h2><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
  </p><p>💩 <span id="💩"></span>
  </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
  </p>
  !! end
 +
 +!! test
 +T90902: Normalize weird characters in section IDs
 +!! config
 +wgFragmentMode=[ 'html5', 'legacy' ]
 +!! wikitext
 +== Foo&nbsp;bar ==
 +[[#Foo&nbsp;bar]]
 +
 +!! html/php
 +<h2><span class="mw-headline" id="Foo_bar">Foo&#160;bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<p><a href="#Foo_bar">#Foo&#160;bar</a>
 +</p>
 +!! end