Index: trunk/phase3/thumb.php |
— | — | @@ -46,12 +46,18 @@ |
47 | 47 | * @return void |
48 | 48 | */ |
49 | 49 | function wfThumbHandle404() { |
50 | | - # lighttpd puts the original request in REQUEST_URI, while |
51 | | - # sjs sets that to the 404 handler, and puts the original |
52 | | - # request in REDIRECT_URL. |
| 50 | + # lighttpd puts the original request in REQUEST_URI, while sjs sets |
| 51 | + # that to the 404 handler, and puts the original request in REDIRECT_URL. |
53 | 52 | if ( isset( $_SERVER['REDIRECT_URL'] ) ) { |
54 | | - # The URL is un-encoded, so put it back how it was. |
| 53 | + # The URL is un-encoded, so put it back how it was |
55 | 54 | $uri = str_replace( "%2F", "/", urlencode( $_SERVER['REDIRECT_URL'] ) ); |
| 55 | + # Just get the URI path (REDIRECT_URL is either a full URL or a path) |
| 56 | + if ( $uri[0] !== '/' ) { |
| 57 | + $bits = wfParseUrl( $uri ); |
| 58 | + if ( $bits && isset( $bits['path'] ) ) { |
| 59 | + $uri = $bits['path']; |
| 60 | + } |
| 61 | + } |
56 | 62 | } else { |
57 | 63 | $uri = $_SERVER['REQUEST_URI']; |
58 | 64 | } |
— | — | @@ -215,18 +221,23 @@ |
216 | 222 | * Extract the required params for thumb.php from the thumbnail request URI. |
217 | 223 | * At least 'width' and 'f' should be set if the result is an array. |
218 | 224 | * |
219 | | - * @param $uri String Thumbnail request URI |
| 225 | + * @param $uri String Thumbnail request URI path |
220 | 226 | * @return Array|null associative params array or null |
221 | 227 | */ |
222 | 228 | function wfExtractThumbParams( $uri ) { |
223 | 229 | $repo = RepoGroup::singleton()->getLocalRepo(); |
224 | 230 | |
| 231 | + $bits = wfParseUrl( $repo->getZoneUrl( 'thumb' ) ); |
| 232 | + if ( !$bits ) { |
| 233 | + return null; |
| 234 | + } |
| 235 | + $zoneUrlRegex = preg_quote( $bits['path'] ); |
| 236 | + |
225 | 237 | $hashDirRegex = $subdirRegex = ''; |
226 | 238 | for ( $i = 0; $i < $repo->getHashLevels(); $i++ ) { |
227 | 239 | $subdirRegex .= '[0-9a-f]'; |
228 | 240 | $hashDirRegex .= "$subdirRegex/"; |
229 | 241 | } |
230 | | - $zoneUrlRegex = preg_quote( $repo->getZoneUrl( 'thumb' ) ); |
231 | 242 | |
232 | 243 | $thumbUrlRegex = "!^$zoneUrlRegex(/archive|/temp|)/$hashDirRegex([^/]*)/([^/]*)$!"; |
233 | 244 | |