Disable pretty italics inside links. Now the italics inside a link alternate text...
authorPlatonides <platonides@users.mediawiki.org>
Wed, 23 Jun 2010 23:29:54 +0000 (23:29 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Wed, 23 Jun 2010 23:29:54 +0000 (23:29 +0000)
Pretty italics mean that italics go across links: ''Some [[Link|pretty ''italics'' and stuff]]! -> ''Some [[Link|pretty ''italics'' and stuff]]! -> <i>Some <a>pretty <i>italics</i> and stuff</a>!</i>

This also fixes bug 24093, where interface messages saying '''[[$1]]''' has been deleted/renamed/links here were being bitten by this feature.

The best resolution would be to make pretty italics still work inside alternates, feel free to do so, but doesn't seem worth at this point. The right solution should be to rewrite the quotes handling so it takes its scope into account.

includes/Linker.php
includes/parser/Parser.php
maintenance/parserTests.txt

index c7f7df9..f97701f 100644 (file)
@@ -693,11 +693,9 @@ class Linker {
                                list( $inside, $trail ) = self::splitTrail( $trail );
 
                                wfProfileOut( __METHOD__ );
-                               return Html::element( 'a', array(
-                                       'href' => $href,
-                                       'class' => 'new',
-                                       'title' => $title->getPrefixedText()
-                               ), $prefix . $text . $inside ) . $trail;
+                               return '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' . 
+                                                               htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) . '">' .
+                                                               htmlspecialchars( $prefix . $text . $inside, ENT_NOQUOTES ) . '</a>' . $trail;
                        } else {
                                wfProfileOut( __METHOD__ );
                                return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
@@ -751,7 +749,7 @@ class Linker {
                                $url = $this->getUploadUrl( $title );
                                $class = 'new';
                        }
-                       $alt = htmlspecialchars( $title->getText() );
+                       $alt = htmlspecialchars( $title->getText(),  ENT_QUOTES );
                        if( $text == '' ) {
                                $text = $alt;
                        }
index 2a68198..421bbb1 100644 (file)
@@ -1072,9 +1072,9 @@ class Parser {
                        $df = DateFormatter::getInstance();
                        $text = $df->reformat( $this->mOptions->getDateFormat(), $text );
                }
-               $text = $this->doAllQuotes( $text );
                $text = $this->replaceInternalLinks( $text );
                $text = $this->replaceExternalLinks( $text );
+               $text = $this->doAllQuotes( $text );
 
                # replaceInternalLinks may sometimes leave behind
                # absolute URLs, which have to be masked to hide them from replaceExternalLinks
@@ -1841,6 +1841,11 @@ class Parser {
                        $wasblank = ( $text  == '' );
                        if ( $wasblank ) {
                                $text = $link;
+                       } else {
+                               # Bug 4598 madness. Handle the quotes only if they come from the alternate part
+                               # [[Lista d''e paise d''o munno]] -> <a href="">Lista d''e paise d''o munno</a>
+                               # [[Criticism of Harry Potter|Criticism of ''Harry Potter'']] -> <a href="Criticism of Harry Potter">Criticism of <i>Harry Potter</i></a>
+                               $text = $this->doQuotes($text);
                        }
 
                        # Link not escaped by : , create the various objects
index 49ceba2..bf94ea8 100644 (file)
@@ -1462,12 +1462,10 @@ Link containing "<#" and ">#" as a hex sequences
 
 !! test
 Link containing double-single-quotes '' (bug 4598)
-!! options
-disabled
 !! input
 [[Lista d''e paise d''o munno]]
 !! result
-<p><a href="/index.php?title=Lista_d%27%27e_paise_d%27%27o_munno&amp;action=edit" class="new" title="Lista d''e paise d''o munno">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''e paise d''o munno (page does not exist)">Lista d''e paise d''o munno</a>
 </p>
 !! end
 
@@ -1485,7 +1483,25 @@ Link containing double-single-quotes '' in text embedded in italics (bug 4598 sa
 !! input
 ''Some [[Link|pretty ''italics'' and stuff]]!
 !! result
-<p><i>Some </i><a href="/index.php?title=Link&amp;action=edit&amp;redlink=1" class="new" title="Link (page does not exist)"><i>pretty </i>italics<i> and stuff</i></a><i>!</i>
+<p><i>Some <a href="/index.php?title=Link&amp;action=edit&amp;redlink=1" class="new" title="Link (page does not exist)">pretty <i>italics</i> and stuff</a>!</i>
+</p>
+!! end
+
+!! test
+Link with double quotes in title part (literal) and alternate part (interpreted)
+!! input
+[[File:Denys Savchenko ''Pentecoste''.jpg]]
+
+[[''Pentecoste'']]
+
+[[''Pentecoste''|Pentecoste]]
+
+[[''Pentecoste''|''Pentecoste'']]
+!! result
+<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>
 !! end