Index: includes/filerepo/File.php =================================================================== --- includes/filerepo/File.php (revision 32181) +++ includes/filerepo/File.php (working copy) @@ -90,6 +90,30 @@ } /** + * Convert a filename into a form required by the local filesystem. + * + * @param $utf8name Original filename (in UTF-8) + * @return Encoded filename + * @private + */ + static function nameToFSCharset( $utf8name ) { + global $wgLocalFilesystemCharsetOverride; + return $wgLocalFilesystemCharsetOverride ? iconv( 'UTF-8', $wgLocalFilesystemCharsetOverride, $utf8name ) : $utf8name; + } + + /** + * Convert a filename from an encoded form. + * + * @param $fsname Encoded filename + * @return Normal filename (in UTF-8) + * @private + */ + static function nameFromFSCharset( $fsname ) { + global $wgLocalFilesystemCharsetOverride; + return $wgLocalFilesystemCharsetOverride ? iconv( $wgLocalFilesystemCharsetOverride, 'UTF-8', $fsname ) : $fsname; + } + + /** * Upgrade the database row if there is one * Called by ImagePage * STUB @@ -147,7 +171,7 @@ } return $this->url; } - + /** * Return a fully-qualified URL to the file. * Upload URL paths _may or may not_ be fully qualified, so @@ -433,7 +457,7 @@ } $extension = $this->getExtension(); list( $thumbExt, $thumbMime ) = $this->handler->getThumbType( $extension, $this->getMimeType() ); - $thumbName = $this->handler->makeParamString( $params ) . '-' . $this->getName(); + $thumbName = $this->handler->makeParamString( $params ) . '-' . self::nameToFSCharset( $this->getName() ); if ( $thumbExt != $extension ) { $thumbName .= ".$thumbExt"; } @@ -691,7 +715,7 @@ * Get the path of the file relative to the public zone root */ function getRel() { - return $this->getHashPath() . $this->getName(); + return $this->getHashPath() . self::nameToFSCharset( $this->getName() ); } /** @@ -746,7 +770,7 @@ function getThumbUrl( $suffix = false ) { $path = $this->repo->getZoneUrl('public') . '/thumb/' . $this->getUrlRel(); if ( $suffix !== false ) { - $path .= '/' . rawurlencode( $suffix ); + $path .= '/' . rawurlencode( self::nameFromFSCharset( $suffix ) ); } return $path; } Index: includes/DefaultSettings.php =================================================================== --- includes/DefaultSettings.php (revision 32181) +++ includes/DefaultSettings.php (working copy) @@ -228,6 +228,14 @@ /**#@-*/ /** + * Character encoding of the local filesystem used to convert charset in names of uploaded files. + * null means no charset conversion + * + * E.g. for Windows, this might be something like $wgLocalFilesystemCharsetOverride = 'CP1250'; + */ +$wgLocalFilesystemCharsetOverride = null; + +/** * Allowed title characters -- regex character class * Don't change this unless you know what you're doing *