r98440 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98439‎ | r98440 | r98441 >
Date:20:21, 29 September 2011
Author:johnduhart
Status:ok (Comments)
Tags:
Comment:
Followup r95921, clearer PHPDoc and better variable names per CR
Modified paths:
  • /trunk/phase3/includes/WebRequest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WebRequest.php
@@ -239,15 +239,18 @@
240240 * used for undoing the evil that is magic_quotes_gpc.
241241 *
242242 * @param $arr array: will be modified
243 - * @param $recursion bool Used to modify behaviour based on recursion
 243+ * @param $topLevel bool Specifies if the array passed is from the top
 244+ * level of the source. In PHP5 magic_quotes only escapes the first level
 245+ * of keys that belong to an array.
244246 * @return array the original array
 247+ * @see http://www.php.net/manual/en/function.get-magic-quotes-gpc.php#49612
245248 */
246 - private function &fix_magic_quotes( &$arr, $recursion = false ) {
 249+ private function &fix_magic_quotes( &$arr, $topLevel = true ) {
247250 $clean = array();
248251 foreach( $arr as $key => $val ) {
249252 if( is_array( $val ) ) {
250 - $cleanKey = !$recursion ? stripslashes( $key ) : $key;
251 - $clean[$cleanKey] = $this->fix_magic_quotes( $arr[$key], true );
 253+ $cleanKey = $topLevel ? stripslashes( $key ) : $key;
 254+ $clean[$cleanKey] = $this->fix_magic_quotes( $arr[$key], false );
252255 } else {
253256 $cleanKey = stripslashes( $key );
254257 $clean[$cleanKey] = stripslashes( $val );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95921(bug 4381) Magic quotes cleaning is not comprehensive, key strings not unescapedjohnduhart23:15, 31 August 2011

Comments

#Comment by Nikerabbit (talk | contribs)   04:58, 30 September 2011

Nice!

Status & tagging log