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.
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 );
$url = $this->getUploadUrl( $title );
$class = 'new';
}
- $alt = htmlspecialchars( $title->getText() );
+ $alt = htmlspecialchars( $title->getText(), ENT_QUOTES );
if( $text == '' ) {
$text = $alt;
}
$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
$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
!! 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&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&action=edit&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
!! input
''Some [[Link|pretty ''italics'' and stuff]]!
!! result
-<p><i>Some </i><a href="/index.php?title=Link&action=edit&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&action=edit&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&wpDestFile=Denys_Savchenko_%27%27Pentecoste%27%27.jpg" class="new" title="File:Denys Savchenko ''Pentecoste''.jpg">File:Denys Savchenko <i>Pentecoste</i>.jpg</a>
+</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&action=edit&redlink=1" class="new" title="''Pentecoste'' (page does not exist)">''Pentecoste''</a>
+</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&action=edit&redlink=1" class="new" title="''Pentecoste'' (page does not exist)">Pentecoste</a>
+</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&action=edit&redlink=1" class="new" title="''Pentecoste'' (page does not exist)"><i>Pentecoste</i></a>
</p>
!! end