r37733 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37732‎ | r37733 | r37734 >
Date:23:02, 15 July 2008
Author:catrope
Status:old
Tags:
Comment:
*Really* doing the redircite thing right this time (I hope), now using Xml::escapeJsString() and Xml::tags() to escape stuff.
Modified paths:
  • /trunk/extensions/redircite/redircite.php (modified) (history)

Diff [purge]

Index: trunk/extensions/redircite/redircite.php
@@ -1,7 +1,5 @@
22 <?php
33
4 -die("redircite extension disabled -- contains HTML injection vulnerabilities.");
5 -
64 /**
75 * This program is free software; you can redistribute it and/or modify
86 * it under the terms of the GNU General Public License as published by
@@ -50,11 +48,15 @@
5149 // which will be translated to the HTML stored in $redirciteMarkerList by
5250 // redircite_afterTidy()
5351 global $redirciteMarkerList;
 52+ # Verify that $input is a valid title
 53+ $inputTitle = Title::newFromText($input);
 54+ if(!$inputTitle)
 55+ return $input;
5456 $lparse = clone $parser;
5557 $link1 = $lparse->parse("[[$input]]", $parser->mTitle, $parser->mOptions, false, false);
5658 $link1text = $link1->getText();
5759 $title1 = Title::newFromText($input);
58 - if(!$title1) // Page doesn't exist
 60+ if(!$title1->exists()) // Page doesn't exist
5961 // Just output a normal (red) link
6062 return $link1text;
6163 $articleObj = new Article($title1);
@@ -67,7 +69,12 @@
6870 $link2text = $link2->getText();
6971
7072 $marker = "xx-redircite-marker-" . count($redirciteMarkerList) . "-redircite-xx";
71 - $redirciteMarkerList[] = "<span onmouseout='this.firstChild.innerHTML = \"$input\";' onmouseover='this.firstChild.innerHTML = \"{$title2->getPrefixedText()}\";'>$link2text</span>";
 73+ $onmouseout = 'this.firstChild.innerHTML = "'. Xml::escapeJsString($input) . '";';
 74+ $onmouseover = 'this.firstChild.innerHTML = "' . Xml::escapeJsString($title2->getPrefixedText()) . '";';
 75+ $redirciteMarkerList[] = Xml::tags('span', array(
 76+ 'onmouseout' => $onmouseout,
 77+ 'onmouseover' => $onmouseover),
 78+ $link2text);
7279 return $marker;
7380 }
7481

Status & tagging log