From e7d06d4aff883c8a9ff9f792ecee36184b25ccf7 Mon Sep 17 00:00:00 2001 From: Platonides Date: Wed, 23 Jun 2010 23:29:54 +0000 Subject: [PATCH] Disable pretty italics inside links. Now the italics inside a link alternate text will be handled on its own scope but if they come from the page title, they won't be parsed at all. This is a middle way solution to bug 4598. Now all bug 4598 tests pass. Pretty italics mean that italics go across links: ''Some [[Link|pretty ''italics'' and stuff]]! -> ''Some [[Link|pretty ''italics'' and stuff]]! -> Some pretty italics and stuff! 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 | 10 ++++------ includes/parser/Parser.php | 7 ++++++- maintenance/parserTests.txt | 24 ++++++++++++++++++++---- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index c7f7df9df6..f97701ffa3 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -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 '' . + htmlspecialchars( $prefix . $text . $inside, ENT_NOQUOTES ) . '' . $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; } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 2a681980ce..421bbb1e2b 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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]] -> Lista d''e paise d''o munno + # [[Criticism of Harry Potter|Criticism of ''Harry Potter'']] -> Criticism of Harry Potter + $text = $this->doQuotes($text); } # Link not escaped by : , create the various objects diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index 49ceba293c..bf94ea81be 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -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 -

Lista d''e paise d''o munno +

Lista d''e paise d''o munno

!! 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 -

Some pretty italics and stuff! +

Some pretty italics and stuff! +

+!! 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 +

File:Denys Savchenko Pentecoste.jpg +

''Pentecoste'' +

Pentecoste +

Pentecoste

!! end -- 2.20.1