Merge "Don't link wikilinks in section heading autocomments"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 3 Dec 2018 21:35:28 +0000 (21:35 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 3 Dec 2018 21:35:28 +0000 (21:35 +0000)
includes/Linker.php
tests/parser/parserTests.txt
tests/phpunit/includes/LinkerTest.php

index e96d8d8..2028197 100644 (file)
@@ -1159,6 +1159,10 @@ class Linker {
                                                $section = str_replace( '[[', '', $section );
                                                $section = str_replace( ']]', '', $section );
 
+                                               // We don't want any links in the auto text to be linked, but we still
+                                               // want to show any [[ ]]
+                                               $sectionText = str_replace( '[[', '&#91;[', $auto );
+
                                                $section = substr( Parser::guessSectionNameFromStrippedText( $section ), 1 );
                                                if ( $local ) {
                                                        $sectionTitle = Title::makeTitleSafe( NS_MAIN, '', $section );
@@ -1168,7 +1172,7 @@ class Linker {
                                                }
                                                if ( $sectionTitle ) {
                                                        $auto = Linker::makeCommentLink(
-                                                               $sectionTitle, $wgLang->getArrow() . $wgLang->getDirMark() . $auto,
+                                                               $sectionTitle, $wgLang->getArrow() . $wgLang->getDirMark() . $sectionText,
                                                                $wikiId, 'noclasses'
                                                        );
                                                }
index bbacfaf..025ebc0 100644 (file)
@@ -24525,6 +24525,26 @@ comment local title=[[Main Page]]
 <span dir="auto"><span class="autocomment"><a href="#External_links">→‎External links</a>: </span> removed bogus entries</span>
 !!end
 
+!! test
+Edit comment with section link that has a link in it
+!! options
+comment local title=[[Main Page]]
+!! wikitext
+/* [[A link]] */
+!! html/php
+<span dir="auto"><span class="autocomment"><a href="#A_link">→‎&#91;[A link]]</a></span></span>
+!! end
+
+!! test
+Edit comment with section link that has a template in it
+!! options
+comment local title=[[Main Page]]
+!! wikitext
+/* {{foobar|param}} */
+!! html/php
+<span dir="auto"><span class="autocomment"><a href="#.7B.7Bfoobar.7Cparam.7D.7D">→‎{{foobar|param}}</a></span></span>
+!! end
+
 !! test
 Edit comment with subpage link (T16080)
 !! options
index 1f8f438..34e5593 100644 (file)
@@ -156,7 +156,7 @@ class LinkerTest extends MediaWikiLangTestCase {
                                "/* autocomment */",
                        ],
                        [
-                               '<span dir="auto"><span class="autocomment"><a href="/wiki/Special:BlankPage#linkie.3F" title="Special:BlankPage">→‎<a href="/wiki/index.php?title=Linkie%3F&amp;action=edit&amp;redlink=1" class="new" title="Linkie? (page does not exist)">linkie?</a></a></span></span>',
+                               '<span dir="auto"><span class="autocomment"><a href="/wiki/Special:BlankPage#linkie.3F" title="Special:BlankPage">→‎&#91;[linkie?]]</a></span></span>',
                                "/* [[linkie?]] */",
                        ],
                        [