You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The mimetype of Word2007 documents generated by PHPWord 0.14/0.16 cannot be determined correctly neither by Ubuntu 16.04 "file" command nor by PHP 7.2 finfo's bytestream mimetype guesser.
Ubuntu's file command and PHP 7.2's finfo command both read the files as binary and determine their mimetype based on logic, which parses the file's bytestream hexadecimal values.
When determining the mimetype of Word2007 documents generated by PHPWord 0.14/0.16, both executables fail to do so, hence returning "application/octet-stream".
In our application we rely on determining the mimetype, instead of trusting the meta info "Content-Type". Due to security reasons we don't allow uploading "application/octet-stream" which makes it impossible for us to upload files, generated by ourselves using PHPWord.
Steps to Reproduce
Execute the following code, taken from PHPWord's documentation
<?phprequire __DIR__ . '/vendor/autoload.php';
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->addText( '"Learn from yesterday, live for today, hope for tomorrow. '
. 'The important thing is not to stop questioning." (Albert Einstein)');
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('helloWorld.docx');
Execute "file --mime-type -b {PATH_TO_FILE}"
Expected Behavior
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" is returned
Current Behavior
"application/octet-stream" is returned
Context
PHP Version: 7.2
PHPWord Version: 0.14, 0.16
The text was updated successfully, but these errors were encountered:
vitanivanov
changed the title
The bytestream of word documents generated by PHPWord 0.14 cannot be determined
The bytestream of word documents generated by PHPWord 0.14/0.16 is incompatible with bytestream mimetype guessers
Nov 13, 2019
vitanivanov
changed the title
The bytestream of word documents generated by PHPWord 0.14/0.16 is incompatible with bytestream mimetype guessers
Word documents generated by PHPWord 0.14/0.16 are incompatible with "finfo" and "file" bytestream mimetype guessers
Nov 13, 2019
The mimetype of Word2007 documents generated by PHPWord 0.14/0.16 cannot be determined correctly neither by Ubuntu 16.04 "file" command nor by PHP 7.2 finfo's bytestream mimetype guesser.
Ubuntu's file command and PHP 7.2's finfo command both read the files as binary and determine their mimetype based on logic, which parses the file's bytestream hexadecimal values.
When determining the mimetype of Word2007 documents generated by PHPWord 0.14/0.16, both executables fail to do so, hence returning "application/octet-stream".
In our application we rely on determining the mimetype, instead of trusting the meta info "Content-Type". Due to security reasons we don't allow uploading "application/octet-stream" which makes it impossible for us to upload files, generated by ourselves using PHPWord.
Steps to Reproduce
Expected Behavior
"application/vnd.openxmlformats-officedocument.wordprocessingml.document" is returned
Current Behavior
"application/octet-stream" is returned
Context
The text was updated successfully, but these errors were encountered: