r104216 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104215‎ | r104216 | r104217 >
Date:02:21, 25 November 2011
Author:aaron
Status:ok
Tags:
Comment:
FU r103738: redid the method of getting the source file name for thumbnails altogether, using suggestion per CR.
Modified paths:
  • /trunk/phase3/img_auth.php (modified) (history)

Diff [purge]

Index: trunk/phase3/img_auth.php
@@ -94,12 +94,13 @@
9595 return;
9696 }
9797
98 - // Extract the file name and chop off the size specifier
 98+ // Extract the file name and chop off the size specifier.
9999 // (e.g. 120px-Foo.png => Foo.png or page2-120px-Foo.png => Foo.png).
100 - // This only applies to thumbnails, and all thumbnails have a -px specifier.
 100+ // This only applies to thumbnails, and all thumbnails should
 101+ // be under a folder that has the source file name.
101102 $name = wfBaseName( $path );
102 - if ( preg_match( '!(?:[^-]*-)*?\d+px-(.*)!i', $name, $m ) ) {
103 - $name = $m[1]; // this file is a thumbnail
 103+ if ( strpos( $path, '/thumb/' ) === 0 ) {
 104+ $name = wfBaseName( dirname( $path ) ); // this file is a thumbnail
104105 }
105106
106107 $title = Title::makeTitleSafe( NS_FILE, $name );
@@ -116,7 +117,7 @@
117118
118119 // Check user authorization for this title
119120 // UserCanRead Checks Whitelist too
120 - if( !$title->userCanRead() ) {
 121+ if ( !$title->userCanRead() ) {
121122 wfForbidden( 'img-auth-accessdenied', 'img-auth-noread', $name );
122123 return;
123124 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r105208FU r104216: keep the r103738 regex check for thumbnails but use the parent di...aaron19:17, 5 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103738image_auth.php cleanups:...aaron08:50, 20 November 2011

Status & tagging log