edwardspec / mediawiki-aws-s3

Extension:AWS allows MediaWiki to use Amazon S3 (instead of the local directory) to store images.
https://www.mediawiki.org/wiki/Extension:AWS
GNU General Public License v2.0
42 stars 32 forks source link

Headers set by MediaWiki are not being set in S3 backend #49

Closed Sazpaimon closed 2 years ago

Sazpaimon commented 2 years ago

I'm setting a Content-Disposition header in mediawiki (to download certain files with their original name and not with underscores). Unfortunately, the S3 client does not properly read these headers, as sanitizeOpHeaders converts all header keys to lowercase, but the S3 backend is hardcoding the expected header names to Content-Disposition and looking for that header in $params['headers']. Ideally, the S3 backend should do something like:

        $params['headers'] += array_fill_keys( [
            'cache-control',
            'content-disposition',
            'content-encoding',
            'content-language',
            'content-type',
            'expires',
            'e-tag',
            'if-modified-since'
        ], null );

to use lowercase keys in order to use any value set by Mediawiki earlier.

edwardspec commented 2 years ago

Problem confirmed. All uses of $params["headers"]["header-name"] in AmazonS3FileBackend::createOrStore() should be made case-insensitive.

edwardspec commented 2 years ago

Should be fixed now.