r9842 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r9841‎ | r9842 | r9843 >
Date:23:36, 2 July 2005
Author:vibber
Status:old
Tags:
Comment:
Tweaking HTML escaping/output:
* Move escaping to the output steps (it's part of output protocol)
* Escape plaintext UI messages
Modified paths:
  • /trunk/extensions/inputbox/inputbox.php (modified) (history)

Diff [purge]

Index: trunk/extensions/inputbox/inputbox.php
@@ -38,10 +38,7 @@
3939 getBoxOption($width,$input,"width");
4040 getBoxOption($preload,$input,"preload");
4141 getBoxOption($editintro,$input,"editintro");
42 - # Escapin' time
43 - $preload=wfEscapeWikiText($preload);
44 - $editintro=wfEscapeWikiText($editintro);
45 - $width=intval($width);
 42+
4643 if($type=="search") {
4744 $inputbox=getSearchForm($width);
4845 } elseif($type=="create") {
@@ -56,13 +53,17 @@
5754 }
5855
5956 function getSearchForm($width) {
 57+ global $wgUser;
 58+
 59+ $width=intval($width);
 60+ if(!$width) $width=45;
6061
61 - global $wgArticlePath,$wgUser;
62 - if(!$width) $width=45;
6362 $sk=$wgUser->getSkin();
64 - $searchpath=$sk->escapeSearchLink();
65 - $tryexact=wfMsg('tryexact');
66 - $searchfulltext=wfMsg('searchfulltext');
 63+ $searchpath = $sk->escapeSearchLink();
 64+
 65+ $tryexact = wfMsgHtml( 'tryexact' );
 66+ $searchfulltext = wfMsgHtml( 'searchfulltext' );
 67+
6768 $searchform=<<<ENDFORM
6869 <table border="0" width="100%">
6970 <tr>
@@ -84,18 +85,25 @@
8586 }
8687
8788 function getCreateForm($width,$preload='',$editintro='') {
 89+ global $wgScript;
8890
89 - global $wgScript;
90 - if(!$width) $width=45;
91 - $createarticle=wfMsg("createarticle");
 91+ $width=intval($width);
 92+ if(!$width) $width = 45;
 93+
 94+ $action = htmlspecialchars( $wgScript );
 95+ $preloadEnc = htmlspecialchars( $preload );
 96+ $editintroEnc = htmlspecialchars( $editintro );
 97+
 98+ $createarticle = wfMsgHtml( "createarticle" );
 99+
92100 $createform=<<<ENDFORM
93101 <table border="0" width="100%">
94102 <tr>
95103 <td align="center">
96 -<form name="createbox" action="{$wgScript}" method="get" id="createbox">
 104+<form name="createbox" action="$action" method="get" id="createbox">
97105 <input type='hidden' name="action" value="edit">
98 - <input type="hidden" name="preload" value="$preload" />
99 - <input type="hidden" name="editintro" value="$editintro" />
 106+ <input type="hidden" name="preload" value="$preloadEnc" />
 107+ <input type="hidden" name="editintro" value="$editintroEnc" />
100108 <input id="createboxInput" name="title" type="text"
101109 value="" size="$width"/><br />
102110 <input type='submit' name="create" id="createboxButton"

Status & tagging log