From: Sam Reed Date: Sat, 15 Oct 2011 22:58:42 +0000 (+0000) Subject: Fix whitespace, braces X-Git-Tag: 1.31.0-rc.0~27080 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=d90b987ade2a6a349ec8f59c2a445374069be948;p=lhc%2Fweb%2Fwiklou.git Fix whitespace, braces Fix return items --- diff --git a/img_auth.php b/img_auth.php index 9b330ce2d4..069db6ce86 100644 --- a/img_auth.php +++ b/img_auth.php @@ -50,8 +50,7 @@ $whitelist = array(); if ( $dotPos !== false ) { $whitelist[] = substr( $path, $dotPos + 1 ); } -if ( !$wgRequest->checkUrlExtension( $whitelist ) ) -{ +if ( !$wgRequest->checkUrlExtension( $whitelist ) ) { return; } @@ -59,38 +58,44 @@ $filename = realpath( $wgUploadDirectory . $path ); $realUpload = realpath( $wgUploadDirectory ); // Basic directory traversal check -if( substr( $filename, 0, strlen( $realUpload ) ) != $realUpload ) +if( substr( $filename, 0, strlen( $realUpload ) ) != $realUpload ) { wfForbidden('img-auth-accessdenied','img-auth-notindir'); +} // Extract the file name and chop off the size specifier // (e.g. 120px-Foo.png => Foo.png) $name = wfBaseName( $path ); -if( preg_match( '!\d+px-(.*)!i', $name, $m ) ) +if( preg_match( '!\d+px-(.*)!i', $name, $m ) ) { $name = $m[1]; +} // Check to see if the file exists -if( !file_exists( $filename ) ) +if( !file_exists( $filename ) ) { wfForbidden('img-auth-accessdenied','img-auth-nofile',$filename); +} // Check to see if tried to access a directory -if( is_dir( $filename ) ) +if( is_dir( $filename ) ) { wfForbidden('img-auth-accessdenied','img-auth-isdir',$filename); - +} $title = Title::makeTitleSafe( NS_FILE, $name ); // See if could create the title object -if( !$title instanceof Title ) +if( !$title instanceof Title ) { wfForbidden('img-auth-accessdenied','img-auth-badtitle',$name); +} // Run hook -if (!wfRunHooks( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) ) +if (!wfRunHooks( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) ) { wfForbidden($result[0],$result[1],array_slice($result,2)); +} // Check user authorization for this title // UserCanRead Checks Whitelist too -if( !$title->userCanRead() ) +if( !$title->userCanRead() ) { wfForbidden('img-auth-accessdenied','img-auth-noread',$name); +} // Stream the requested file wfDebugLog( 'img_auth', "Streaming `".$filename."`." ); @@ -101,16 +106,18 @@ wfLogProfilingData(); * Issue a standard HTTP 403 Forbidden header ($msg1-a message index, not a message) and an * error message ($msg2, also a message index), (both required) then end the script * subsequent arguments to $msg2 will be passed as parameters only for replacing in $msg2 + * @param $msg1 + * @param $msg2 */ -function wfForbidden($msg1,$msg2) { +function wfForbidden( $msg1, $msg2 ) { global $wgImgAuthDetails; $args = func_get_args(); array_shift( $args ); array_shift( $args ); - $MsgHdr = htmlspecialchars(wfMsg($msg1)); - $detailMsg = (htmlspecialchars(wfMsg(($wgImgAuthDetails ? $msg2 : 'badaccess-group0'),$args))); - wfDebugLog('img_auth', "wfForbidden Hdr:".wfMsgExt( $msg1, array('language' => 'en'))." Msg: ". - wfMsgExt($msg2,array('language' => 'en'),$args)); + $MsgHdr = htmlspecialchars( wfMsg( $msg1 ) ); + $detailMsg = ( htmlspecialchars( wfMsg( ( $wgImgAuthDetails ? $msg2 : 'badaccess-group0' ), $args ) ) ); + wfDebugLog('img_auth', "wfForbidden Hdr:".wfMsgExt( $msg1, array( 'language' => 'en' ) )." Msg: ". + wfMsgExt( $msg2, array('language' => 'en' ), $args ) ); header( 'HTTP/1.0 403 Forbidden' ); header( 'Cache-Control: no-cache' ); header( 'Content-Type: text/html; charset=utf-8' ); diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index c5fc087746..6f35686f2a 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -296,7 +296,7 @@ function wfUrlencode( $s ) { static $needle; if ( is_null( $s ) ) { $needle = null; - return; + return ''; } if ( is_null( $needle ) ) { @@ -537,6 +537,7 @@ function wfUrlProtocols( $includeProtocolRelative = true ) { * Like wfUrlProtocols(), but excludes '//' from the protocol list. Use this if * you need a regex that matches all URL protocols but does not match protocol- * relative URLs + * @return String */ function wfUrlProtocolsWithoutProtRel() { return wfUrlProtocols( false ); @@ -960,6 +961,9 @@ function wfReadOnly() { return (bool)$wgReadOnly; } +/** + * @return bool + */ function wfReadOnlyReason() { global $wgReadOnly; wfReadOnly(); @@ -2888,6 +2892,7 @@ function wfRelativePath( $path, $from ) { * * @deprecated since 1.19 * @see DeferredUpdates::doUpdate() + * @param $commit string */ function wfDoUpdates( $commit = '' ) { DeferredUpdates::doUpdates( $commit ); @@ -2985,6 +2990,7 @@ function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, $lowercase = t * * @param $name String * @param $p Array: parameters + * @return object * @deprecated since 1.18, warnings in 1.18, removal in 1.20 */ function wfCreateObject( $name, $p ) { @@ -2992,6 +2998,9 @@ function wfCreateObject( $name, $p ) { return MWFunction::newObj( $name, $p ); } +/** + * @return bool + */ function wfHttpOnlySafe() { global $wgHttpOnlyBlacklist; @@ -3122,7 +3131,6 @@ function wfWikiID() { * Split a wiki ID into DB name and table prefix * * @param $wiki String - * @param $bits String * * @return array */ @@ -3382,7 +3390,6 @@ function wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) { * * @param $maxLag Integer (deprecated) * @param $wiki mixed Wiki identifier accepted by wfGetLB - * @return null */ function wfWaitForSlaves( $maxLag = false, $wiki = false ) { $lb = wfGetLB( $wiki ); @@ -3414,6 +3421,7 @@ function wfOut( $s ) { * Count down from $n to zero on the terminal, with a one-second pause * between showing each number. For use in command-line scripts. * @codeCoverageIgnore + * @param $n int */ function wfCountDown( $n ) { for ( $i = $n; $i >= 0; $i-- ) { @@ -3522,7 +3530,7 @@ function wfShorthandToInteger( $string = '' ) { * See unit test for examples. * * @param $code String: The language code. - * @return $langCode String: The language code which complying with BCP 47 standards. + * @return String: The language code which complying with BCP 47 standards. */ function wfBCP47( $code ) { $codeSegment = explode( '-', $code ); diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 69f01b48b3..f62be8b67b 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -15,7 +15,6 @@ abstract class Page {} class WikiPage extends Page { /** * @var Title - * @protected */ public $mTitle = null; diff --git a/includes/specials/SpecialBrokenRedirects.php b/includes/specials/SpecialBrokenRedirects.php index 35770713bb..61f7e7a6ef 100644 --- a/includes/specials/SpecialBrokenRedirects.php +++ b/includes/specials/SpecialBrokenRedirects.php @@ -22,7 +22,7 @@ */ /** - * A special page listing redirects tonon existent page. Those should be + * A special page listing redirects to non existent page. Those should be * fixed to point to an existing page. * * @ingroup SpecialPage diff --git a/thumb.php b/thumb.php index 61fd788c9b..5eda9f5db6 100644 --- a/thumb.php +++ b/thumb.php @@ -75,7 +75,7 @@ function wfThumbMain() { // Check permissions if there are read restrictions if ( !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) ) { if ( !$img->getTitle()->userCanRead() ) { - wfThumbError( 403, 'Access denied. You do not have permission to access ' . + wfThumbError( 403, 'Access denied. You do not have permission to access ' . 'the source file.' ); wfProfileOut( __METHOD__ ); return; @@ -162,6 +162,10 @@ function wfThumbMain() { wfProfileOut( __METHOD__ ); } +/** + * @param $status + * @param $msg + */ function wfThumbError( $status, $msg ) { global $wgShowHostnames; header( 'Cache-Control: no-cache' ); diff --git a/trackback.php b/trackback.php index 0e2036a92c..1f88af7cda 100644 --- a/trackback.php +++ b/trackback.php @@ -26,6 +26,9 @@ XML; exit; } + /** + * @param $err string + */ private function XMLerror( $err = "Invalid request." ) { header( "HTTP/1.0 400 Bad Request" ); header( "Content-Type: application/xml; charset=utf-8" );