r38944 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38943‎ | r38944 | r38945 >
Date:20:34, 8 August 2008
Author:brion
Status:old
Tags:
Comment:
Revert r38749, 38750 - prefix search on InterwikiList extension
Form HTML is contructed manually without proper escaping, which at best may lead to invalid output, and is generally a poor practice.
Either use Xml:: element constructor functions (good) or properly escape all output (moderately good)
Modified paths:
  • /trunk/extensions/InterwikiList/InterwikiList.i18n.php (modified) (history)
  • /trunk/extensions/InterwikiList/InterwikiList.php (modified) (history)
  • /trunk/extensions/InterwikiList/InterwikiList_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/InterwikiList/InterwikiList_body.php
@@ -9,9 +9,6 @@
1010
1111 class InterwikiList extends SpecialPage {
1212
13 - // Privates
14 - private $mTitle; // The title for this specialpage
15 -
1613 /**
1714 * Constructor
1815 */
@@ -24,39 +21,21 @@
2522 * Execute
2623 */
2724 public function execute( $par ) {
28 - global $wgOut, $wgRequest;
 25+ global $wgOut;
2926 $wgOut->setPagetitle( wfMsg( 'interwikilist' ) );
30 - $this->mTitle = SpecialPage::getTitleFor( 'InterwikiList' );
31 - $prefix = $wgRequest->getText( 'iwsearch', $par );
32 - $wgOut->addHTML( $this->getInterwikis( $prefix ) );
 27+ $selfTitle = Title::makeTitle( NS_SPECIAL, 'InterwikiList' );
 28+ $wgOut->addHTML( $this->getInterwikis() );
3329 }
3430
3531 /**
3632 * Get all Interwiki Links - the heart of the function
37 - * @param $prefix string Prefix to search for in list
38 - * @return string HTML
3933 */
40 - private function getInterwikis( $prefix = null ) {
41 - global $wgScript;
 34+ private function getInterwikis() {
4235 $dbr = wfGetDB( DB_SLAVE );
43 -
44 - $conds = array();
45 - if ( !is_null( $prefix ) ) {
46 - $conds[] = "iw_prefix LIKE " . $dbr->addQuotes( $dbr->escapeLike( $prefix ) . "%" );
47 - }
48 -
49 - $results = $dbr->select( 'interwiki', array( 'iw_prefix', 'iw_url' ), $conds );
50 -
51 - $text = "<fieldset>\n" .
52 - "<legend>" . wfMsg('interwikilist-filter') . "</legend>\n" .
53 - "<form action=\"". $wgScript . "\" method=\"get\" id=\"interwikilist-search\">\n" .
54 - "<input type=\"hidden\" name=\"title\" value=\"" . $this->mTitle->getPrefixedText() . "\">\n" .
55 - wfMsg('interwikilist-prefix') . " <input type=\"text\" name=\"iwsearch\" id=\"interwikilist-prefix\" value=\"" .
56 - htmlspecialchars( $prefix ) . "\"><br />\n" .
57 - "<input type=\"submit\" value=\"" . wfMsg('search') . "\">\n" .
58 - "</form>\n</fieldset>";
59 -
60 - $text .= "<table id=\"sv-software\"<tr>
 36+
 37+ $results = $dbr->select( 'interwiki', array( 'iw_prefix', 'iw_url' ) );
 38+
 39+ $text = Xml::openElement( 'table', array( 'id' => 'sv-software' ) ) . "<tr>
6140 <th>" . wfMsg( 'interwikilist-linkname' ) . "</th>
6241 <th>" . wfMsg( 'interwikilist-target' ) . "</th>
6342 </tr>\n";
@@ -69,7 +48,7 @@
7049 }
7150 $text .= "</table>\n";
7251 $dbr->freeResult( $results );
73 -
 52+
7453 return $text;
7554 }
76 -}
 55+}
\ No newline at end of file
Index: trunk/extensions/InterwikiList/InterwikiList.i18n.php
@@ -9,8 +9,6 @@
1010 'interwikilist-desc' => 'Adds a [[Special:Interwikilist|special page]] to view available interwiki links',
1111 'interwikilist-linkname' => 'Interwiki link',
1212 'interwikilist-target' => 'Target URL',
13 - 'interwikilist-filter' => 'Filter list',
14 - 'interwikilist-prefix' => 'Interwiki prefix:',
1513 );
1614
1715 /** Arabic (العربية)
Index: trunk/extensions/InterwikiList/InterwikiList.php
@@ -11,10 +11,10 @@
1212 * @author Chad Horohoe <innocentkiller@gmail.com>
1313 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1414 */
15 -
 15+
1616 $wgExtensionCredits['specialpage'][] = array(
1717 'name' => 'Interwiki List',
18 - 'version' => '0.3',
 18+ 'version' => '0.2',
1919 'url' => 'http://mediawiki.org/wiki/Extension:InterwikiList',
2020 'description' => 'Adds a [[Special:Interwikilist|special page]] to view available interwiki links',
2121 'author' => '[mailto:innocentkiller@gmail.com Chad Horohoe]',
@@ -25,4 +25,5 @@
2626 $wgSpecialPages['InterwikiList'] = 'InterwikiList';
2727 $wgAutoloadClasses['InterwikiList'] = $dir . 'InterwikiList_body.php';
2828 $wgExtensionMessagesFiles['InterwikiList'] = $dir . 'InterwikiList.i18n.php';
 29+$wgExtensionAliasesFiles['InterwikiList'] = $dir . 'InterwikiList.alias.php';
2930 $wgSpecialPageGroups['InterwikiList'] = 'wiki';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r38749Now with search.demon04:19, 7 August 2008

Status & tagging log