Index: trunk/phase3/img_auth.php |
— | — | @@ -94,12 +94,13 @@ |
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | | - // Extract the file name and chop off the size specifier |
| 98 | + // Extract the file name and chop off the size specifier. |
99 | 99 | // (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. |
101 | 102 | $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 |
104 | 105 | } |
105 | 106 | |
106 | 107 | $title = Title::makeTitleSafe( NS_FILE, $name ); |
— | — | @@ -116,7 +117,7 @@ |
117 | 118 | |
118 | 119 | // Check user authorization for this title |
119 | 120 | // UserCanRead Checks Whitelist too |
120 | | - if( !$title->userCanRead() ) { |
| 121 | + if ( !$title->userCanRead() ) { |
121 | 122 | wfForbidden( 'img-auth-accessdenied', 'img-auth-noread', $name ); |
122 | 123 | return; |
123 | 124 | } |