r56167 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56166‎ | r56167 | r56168 >
Date:04:07, 11 September 2009
Author:jdpond
Status:deferred
Tags:
Comment:
Updated img_auth with code improvements to match 1.16 version - no functional changes
Modified paths:
  • /trunk/extensions/NSFileRepo/REL1_13_0/phase3/img_auth.php (modified) (history)
  • /trunk/extensions/NSFileRepo/REL1_14_0/phase3/img_auth.php (modified) (history)
  • /trunk/extensions/NSFileRepo/REL1_15_0/phase3/img_auth.php (modified) (history)

Diff [purge]

Index: trunk/extensions/NSFileRepo/REL1_13_0/phase3/img_auth.php
@@ -56,31 +56,30 @@
5757
5858 // Check to see if the file exists
5959 if( !file_exists( $filename ) )
60 - wfForbidden('img-auth-accessdenied','img-auth-nofile',htmlspecialchars($filename));
 60+ wfForbidden('img-auth-accessdenied','img-auth-nofile',$filename);
6161
6262 // Check to see if tried to access a directory
6363 if( is_dir( $filename ) )
64 - wfForbidden('img-auth-accessdenied','img-auth-isdir',htmlspecialchars($filename));
 64+ wfForbidden('img-auth-accessdenied','img-auth-isdir',$filename);
6565
6666
6767 $title = Title::makeTitleSafe( NS_FILE, $name );
6868
6969 // See if could create the title object
7070 if( !$title instanceof Title )
71 - wfForbidden('img-auth-accessdenied','img-auth-badtitle',htmlspecialchars($name));
 71+ wfForbidden('img-auth-accessdenied','img-auth-badtitle',$name);
7272
7373 // Run hook
7474 if (!wfRunHooks( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) )
75 - call_user_func_array('wfForbidden',merge_array(array($result[0],$result[1]),array_slice($result,2)));
 75+ wfForbidden($result[0],$result[1],array_slice($result,2));
7676
7777 // Check user authorization for this title
7878 // UserCanRead Checks Whitelist too
79 -if( !$title->userCanRead() )
80 - wfForbidden('img-auth-accessdenied','img-auth-noread',htmlspecialchars($name));
 79+if( !$title->userCanRead() )
 80+ wfForbidden('img-auth-accessdenied','img-auth-noread',$name);
8181
82 -
8382 // Stream the requested file
84 -wfDebugLog( 'img_auth', "Streaming `".htmlspecialchars($filename)."`." );
 83+wfDebugLog( 'img_auth', "Streaming `".$filename."`." );
8584 wfStreamFile( $filename, array( 'Cache-Control: private', 'Vary: Cookie' ) );
8685 wfLogProfilingData();
8786
@@ -95,10 +94,10 @@
9695 $args = func_get_args();
9796 array_shift( $args );
9897 array_shift( $args );
99 - $MsgHdr = wfMsgHTML($msg1);
100 - $detailMsg = call_user_func_array('wfMsgHTML',array_merge(array($wgImgAuthDetails ? $msg2 : 'badaccess-group0'),$args));
 98+ $MsgHdr = htmlspecialchars(wfMsg($msg1));
 99+ $detailMsg = (htmlspecialchars(wfMsg(($wgImgAuthDetails ? $msg2 : 'badaccess-group0'),$args)));
101100 wfDebugLog('img_auth', "wfForbidden Hdr:".wfMsgExt( $msg1, array('language' => 'en'))." Msg: ".
102 - call_user_func_array('wfMsgExt',array_merge( array($msg2, array('language' => 'en')),$args)));
 101+ wfMsgExt($msg2,array('language' => 'en'),$args));
103102 header( 'HTTP/1.0 403 Forbidden' );
104103 header( 'Cache-Control: no-cache' );
105104 header( 'Content-Type: text/html; charset=utf-8' );
Index: trunk/extensions/NSFileRepo/REL1_14_0/phase3/img_auth.php
@@ -56,31 +56,30 @@
5757
5858 // Check to see if the file exists
5959 if( !file_exists( $filename ) )
60 - wfForbidden('img-auth-accessdenied','img-auth-nofile',htmlspecialchars($filename));
 60+ wfForbidden('img-auth-accessdenied','img-auth-nofile',$filename);
6161
6262 // Check to see if tried to access a directory
6363 if( is_dir( $filename ) )
64 - wfForbidden('img-auth-accessdenied','img-auth-isdir',htmlspecialchars($filename));
 64+ wfForbidden('img-auth-accessdenied','img-auth-isdir',$filename);
6565
6666
6767 $title = Title::makeTitleSafe( NS_FILE, $name );
6868
6969 // See if could create the title object
7070 if( !$title instanceof Title )
71 - wfForbidden('img-auth-accessdenied','img-auth-badtitle',htmlspecialchars($name));
 71+ wfForbidden('img-auth-accessdenied','img-auth-badtitle',$name);
7272
7373 // Run hook
7474 if (!wfRunHooks( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) )
75 - call_user_func_array('wfForbidden',merge_array(array($result[0],$result[1]),array_slice($result,2)));
 75+ wfForbidden($result[0],$result[1],array_slice($result,2));
7676
7777 // Check user authorization for this title
7878 // UserCanRead Checks Whitelist too
79 -if( !$title->userCanRead() )
80 - wfForbidden('img-auth-accessdenied','img-auth-noread',htmlspecialchars($name));
 79+if( !$title->userCanRead() )
 80+ wfForbidden('img-auth-accessdenied','img-auth-noread',$name);
8181
82 -
8382 // Stream the requested file
84 -wfDebugLog( 'img_auth', "Streaming `".htmlspecialchars($filename)."`." );
 83+wfDebugLog( 'img_auth', "Streaming `".$filename."`." );
8584 wfStreamFile( $filename, array( 'Cache-Control: private', 'Vary: Cookie' ) );
8685 wfLogProfilingData();
8786
@@ -95,10 +94,10 @@
9695 $args = func_get_args();
9796 array_shift( $args );
9897 array_shift( $args );
99 - $MsgHdr = wfMsgHTML($msg1);
100 - $detailMsg = call_user_func_array('wfMsgHTML',array_merge(array($wgImgAuthDetails ? $msg2 : 'badaccess-group0'),$args));
 98+ $MsgHdr = htmlspecialchars(wfMsg($msg1));
 99+ $detailMsg = (htmlspecialchars(wfMsg(($wgImgAuthDetails ? $msg2 : 'badaccess-group0'),$args)));
101100 wfDebugLog('img_auth', "wfForbidden Hdr:".wfMsgExt( $msg1, array('language' => 'en'))." Msg: ".
102 - call_user_func_array('wfMsgExt',array_merge( array($msg2, array('language' => 'en')),$args)));
 101+ wfMsgExt($msg2,array('language' => 'en'),$args));
103102 header( 'HTTP/1.0 403 Forbidden' );
104103 header( 'Cache-Control: no-cache' );
105104 header( 'Content-Type: text/html; charset=utf-8' );
Index: trunk/extensions/NSFileRepo/REL1_15_0/phase3/img_auth.php
@@ -56,31 +56,30 @@
5757
5858 // Check to see if the file exists
5959 if( !file_exists( $filename ) )
60 - wfForbidden('img-auth-accessdenied','img-auth-nofile',htmlspecialchars($filename));
 60+ wfForbidden('img-auth-accessdenied','img-auth-nofile',$filename);
6161
6262 // Check to see if tried to access a directory
6363 if( is_dir( $filename ) )
64 - wfForbidden('img-auth-accessdenied','img-auth-isdir',htmlspecialchars($filename));
 64+ wfForbidden('img-auth-accessdenied','img-auth-isdir',$filename);
6565
6666
6767 $title = Title::makeTitleSafe( NS_FILE, $name );
6868
6969 // See if could create the title object
7070 if( !$title instanceof Title )
71 - wfForbidden('img-auth-accessdenied','img-auth-badtitle',htmlspecialchars($name));
 71+ wfForbidden('img-auth-accessdenied','img-auth-badtitle',$name);
7272
7373 // Run hook
7474 if (!wfRunHooks( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) )
75 - call_user_func_array('wfForbidden',merge_array(array($result[0],$result[1]),array_slice($result,2)));
 75+ wfForbidden($result[0],$result[1],array_slice($result,2));
7676
7777 // Check user authorization for this title
7878 // UserCanRead Checks Whitelist too
79 -if( !$title->userCanRead() )
80 - wfForbidden('img-auth-accessdenied','img-auth-noread',htmlspecialchars($name));
 79+if( !$title->userCanRead() )
 80+ wfForbidden('img-auth-accessdenied','img-auth-noread',$name);
8181
82 -
8382 // Stream the requested file
84 -wfDebugLog( 'img_auth', "Streaming `".htmlspecialchars($filename)."`." );
 83+wfDebugLog( 'img_auth', "Streaming `".$filename."`." );
8584 wfStreamFile( $filename, array( 'Cache-Control: private', 'Vary: Cookie' ) );
8685 wfLogProfilingData();
8786
@@ -95,10 +94,10 @@
9695 $args = func_get_args();
9796 array_shift( $args );
9897 array_shift( $args );
99 - $MsgHdr = wfMsgHTML($msg1);
100 - $detailMsg = call_user_func_array('wfMsgHTML',array_merge(array($wgImgAuthDetails ? $msg2 : 'badaccess-group0'),$args));
 98+ $MsgHdr = htmlspecialchars(wfMsg($msg1));
 99+ $detailMsg = (htmlspecialchars(wfMsg(($wgImgAuthDetails ? $msg2 : 'badaccess-group0'),$args)));
101100 wfDebugLog('img_auth', "wfForbidden Hdr:".wfMsgExt( $msg1, array('language' => 'en'))." Msg: ".
102 - call_user_func_array('wfMsgExt',array_merge( array($msg2, array('language' => 'en')),$args)));
 101+ wfMsgExt($msg2,array('language' => 'en'),$args));
103102 header( 'HTTP/1.0 403 Forbidden' );
104103 header( 'Cache-Control: no-cache' );
105104 header( 'Content-Type: text/html; charset=utf-8' );

Status & tagging log