Topic on Project:Support desk

Cannot upload PDF file although PDF is a permitted file type

3
Summary by AhmadF.Cheema

Allowed extensions should have a space separating each other.

Herrmanthegerman (talkcontribs)

Hello,

I installed Mediawiki on my NAS using the docker image from

https://github.com/kristophjunge/docker-mediawiki

It is up and running. Even the find VisualEditor works like a charm. I can also upload images using drag & drop into the browser.

However, I failed to upload PDF files. When uploading PDF files I get the error message:

".pdf" is not a permitted file type. Permitted file types are png, gif, jpg, jpeg, webp, png,gif,jpg,jpeg,doc,xls,mpp,pdf,ppt,tiff,bmp,docx,xlsx,pptx,ps,odt,ods,odp,odg

I wonder why this is as PDF is obviously a permitted file type.

According to MediaWiki manual, the default list of allowed extensions is 'png', 'gif', 'jpg', 'jpeg', 'webp' and all others are blocked. To add more extensions, this container provides the environment variable MEDIAWIKI_FILE_EXTENSIONS.

I've set the container's environment variable

MEDIAWIKI_FILE_EXTENSIONS=png,gif,jpg,jpeg,doc,xls,mpp,pdf,ppt,tiff,bmp,docx,xlsx,pptx,ps,odt,ods,odp,odg

In LocalSettings.php (which has been modified to allow to set configuration using docker's environment variables mechanics) this environment variable is read and used add filetype to the $wgFileExtensions array:

if (getenv('MEDIAWIKI_FILE_EXTENSIONS') != <nowiki>''</nowiki>) {
    foreach (explode(', ', getenv('MEDIAWIKI_FILE_EXTENSIONS')) as $extension) {
        $wgFileExtensions[] = trim($extension);
    }
}                                                                      

I don't know where to investigate further to fix this issue...on docker's side or on MediaWiki's side. I also reported this issue here

MarkAHershberger (talkcontribs)

It looks like you should have a space separating the extensions. That is:

 MEDIAWIKI_FILE_EXTENSIONS="png, gif, jpg, jpeg, doc, xls, mpp, pdf, ppt, tiff, bmp, docx, xlsx, pptx, ps, odt, ods, odp, odg"
Herrmanthegerman (talkcontribs)

Thanks. You are correct. I overlooked the space in the delimiter passed to explode(). I simply didn't expect this space there as the following trim() handles whitespace properly.

How can I close this "support request"?