Skip to content

mimetype mismatch (PHP 8.3+) and missing mimetype (PHP 7.4+) for "empty" files (CsvReader) #4521

@DanielRuf

Description

@DanielRuf

https://github.com/PHPOffice/PhpSpreadsheet/blob/master/src/PhpSpreadsheet/Reader/Csv.php#L607 only lists inode/x-empty

But newer PHP and libmagic versions use application/x-empty.

So application/x-empty has to be added.

See also:

At the last link you can also see, that previously an empty file with a crlf (\r\n) resulted in application/octet-stream and results in text/plain for newer PHP versions. Maybe this can be also be covered in PhpSpreadsheet (e.g. by using trim and checking the content before doing the mimetype check)?

The ideal way would be, to treat "empty" files (which should proably also include files with only whitespace characters) as such (application/x-empty) instead of application/octet-stream by PHP itself - or the mimetype text/plain for files with \r\n (to align the behavior to PHP 8.3+) .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions