r38348 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38347‎ | r38348 | r38349 >
Date:10:15, 1 August 2008
Author:rotem
Status:old
Tags:
Comment:
Fixing two double-escaping problems in Linker::link (Xml::element escapes the element text):
* In Linker::userLink - already live in Wikimedia sites.
* When no text is given, i.e. in Linker::linkText.
Also fixing documentation comment to prevent more mistakes.
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -146,7 +146,7 @@
147147 * @param $target Title Can currently only be a Title, but this may
148148 * change to support Images, literal URLs, etc.
149149 * @param $text string The HTML contents of the <a> element, i.e.,
150 - * the link text. This is raw HTML and will not be escaped. If null,
 150+ * the link text. This will be escaped. If null,
151151 * defaults to the prefixed text of the Title; or if the Title is just a
152152 * fragment, the contents of the fragment.
153153 * @param $query array The query string to append to the URL
@@ -287,9 +287,9 @@
288288 # If the target is just a fragment, with no title, we return the frag-
289289 # ment text. Otherwise, we return the title text itself.
290290 if( $target->getPrefixedText() === '' and $target->getFragment() !== '' ) {
291 - return htmlspecialchars( $target->getFragment() );
 291+ return $target->getFragment();
292292 }
293 - return htmlspecialchars( $target->getPrefixedText() );
 293+ return $target->getPrefixedText();
294294 }
295295
296296 /**
@@ -1039,13 +1039,12 @@
10401040 * @private
10411041 */
10421042 function userLink( $userId, $userText ) {
1043 - $encName = htmlspecialchars( $userText );
10441043 if( $userId == 0 ) {
10451044 $page = SpecialPage::getTitleFor( 'Contributions', $userText );
10461045 } else {
10471046 $page = Title::makeTitle( NS_USER, $userText );
10481047 }
1049 - return $this->link( $page, $encName );
 1048+ return $this->link( $page, $userText );
10501049 }
10511050
10521051 /**

Status & tagging log