Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finfo returns wrong mime type for woff/woff2 files #8805

Closed
kojot1234 opened this issue Jun 16, 2022 · 6 comments
Closed

finfo returns wrong mime type for woff/woff2 files #8805

kojot1234 opened this issue Jun 16, 2022 · 6 comments

Comments

@kojot1234
Copy link

Description

Uploaded woff/woff2 return incorrect mime type.

The following code:

// $path is a content of an uploaded woff or woff2 file

$finfo = new \finfo(\FILEINFO_MIME_TYPE));
$mimeType = $finfo->file($path); // returns "application/octet-stream"
echo $mimeType;

Resulted in this output:

returns "application/octet-stream"

But I expected this output instead:

expected result is: "font/woff"

Mime type has been fixed in libmagic/file in version 5.42.

file/file@7a821ae

PHP Version

8.1.7

Operating System

Alpine 3.16

@cmb69
Copy link
Member

cmb69 commented Jun 16, 2022

Thanks for reporting!

We're still on 5.40. We should definitely update "master" (which will become PHP-8.2 in some weeks) to 5.42; I'm not quite sure about 5.41PHP-8.1; maybe just patching our 5.40 would make more sense.

@adoy
Copy link
Member

adoy commented Jun 22, 2022

@weltling You were the last one to update libmagic if i'm not wrong. Do you think it would be possible to update to 5.42 in master ? I would love to help but not sure what's the process to update this lib.

@weltling
Copy link
Contributor

weltling commented Sep 10, 2022

@kojot1234 could you share a suitable file to test this please?

@adoy @cmb69 probably too late for 8.2, but I'll plan to spend time porting the latest libmagic in the coming months. Once ported to main one can see if a backport to 8.2 is acceptable. Small data backports are always possible, anyway, as in most case it's about the magic itself, not about the lib code. Upgrading the lib is not trivial, that's why there's no standard procedure for that.

Thanks

@kojot1234
Copy link
Author

Thank you, I'm not able to attach woff in github, you can grab any of the files from this link: https://filesamples.com/formats/woff

weltling added a commit that referenced this issue Sep 18, 2022
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
weltling added a commit that referenced this issue Sep 18, 2022
* PHP-8.1:
  NEWS: Add entry for GH-8805
weltling added a commit that referenced this issue Sep 18, 2022
[ci skip]

Signed-off-by: Anatol Belski <ab@php.net>
weltling added a commit that referenced this issue Sep 18, 2022
* PHP-8.2:
  NEWS: Add entry for GH-8805
  NEWS: Add entry for GH-8805
@weltling
Copy link
Contributor

weltling commented Oct 2, 2022

@adoy @cmb69 i just went pushing a fresh 5.43 port to master. Given the diffs, i think backporting to 8.2 can be done. There is probably no immediate necessity to backport, but therene's a change in the magic DB features, that would suggest to upgrade so bugfixes are easier. Backporting somewhen early next year after sufficient observation in master is what i'd suggest, if RMs are ok.

Thanks

@adoy
Copy link
Member

adoy commented Oct 3, 2022

@weltling Lgtm. Thanks for your work !

markjaquith pushed a commit to markjaquith/WordPress that referenced this issue Mar 6, 2023
As of PHP 8.1.12, which includes libmagic/file update to version 5.42, the expected mime type for WOFF files has changed to `font/woff`, so the type needs to be adjusted accordingly in `wp_check_filetype_and_ext()` tests.

References:
* [php/php-src#8805 php-src: #8805: finfo returns wrong mime type for woff/woff2 files]
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog]

Follow-up to [40124], [54508], [54509], [54724].

Props costdev, SergeyBiryukov.
Fixes #56817.
Built from https://develop.svn.wordpress.org/trunk@55462


git-svn-id: http://core.svn.wordpress.org/trunk@54995 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this issue Mar 6, 2023
As of PHP 8.1.12, which includes libmagic/file update to version 5.42, the expected mime type for WOFF files has changed to `font/woff`, so the type needs to be adjusted accordingly in `wp_check_filetype_and_ext()` tests.

References:
* [php/php-src#8805 php-src: #8805: finfo returns wrong mime type for woff/woff2 files]
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog]

Follow-up to [40124], [54508], [54509], [54724].

Props costdev, SergeyBiryukov.
Fixes #56817.
Built from https://develop.svn.wordpress.org/trunk@55462


git-svn-id: https://core.svn.wordpress.org/trunk@54995 1a063a9b-81f0-0310-95a4-ce76da25c4cd
pento pushed a commit to WordPress/wordpress-develop that referenced this issue Mar 6, 2023
As of PHP 8.1.12, which includes libmagic/file update to version 5.42, the expected mime type for WOFF files has changed to `font/woff`, so the type needs to be adjusted accordingly in `wp_check_filetype_and_ext()` tests.

References:
* [php/php-src#8805 php-src: #8805: finfo returns wrong mime type for woff/woff2 files]
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog]

Follow-up to [40124], [54508], [54509], [54724].

Props costdev, SergeyBiryukov.
Merges [55462] to the 6.1 branch.
Fixes #56817.

git-svn-id: https://develop.svn.wordpress.org/branches/6.1@55463 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this issue Mar 6, 2023
As of PHP 8.1.12, which includes libmagic/file update to version 5.42, the expected mime type for WOFF files has changed to `font/woff`, so the type needs to be adjusted accordingly in `wp_check_filetype_and_ext()` tests.

References:
* [php/php-src#8805 php-src: #8805: finfo returns wrong mime type for woff/woff2 files]
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog]

Follow-up to [40124], [54508], [54509], [54724].

Props costdev, SergeyBiryukov.
Merges [55462] to the 6.1 branch.
Fixes #56817.
Built from https://develop.svn.wordpress.org/branches/6.1@55463


git-svn-id: http://core.svn.wordpress.org/branches/6.1@54996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
pento pushed a commit to WordPress/wordpress-develop that referenced this issue Mar 9, 2023
As of PHP 8.1.12, which includes libmagic/file update to version 5.42, the expected mime type for WOFF files has changed to `font/woff`, so the type needs to be adjusted accordingly in `wp_check_filetype_and_ext()` tests.

References:
* [php/php-src#8805 php-src: #8805: finfo returns wrong mime type for woff/woff2 files]
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog]

Follow-up to [40124], [54508], [54509], [54724].

Props desrosj, jrf, costdev, SergeyBiryukov.
Merges [55462] to the 5.9 branch.
Fixes #56817.

git-svn-id: https://develop.svn.wordpress.org/branches/5.9@55498 602fd350-edb4-49c9-b593-d223f7449a82
pento pushed a commit to WordPress/wordpress-develop that referenced this issue Mar 9, 2023
As of PHP 8.1.12, which includes libmagic/file update to version 5.42, the expected mime type for WOFF files has changed to `font/woff`, so the type needs to be adjusted accordingly in `wp_check_filetype_and_ext()` tests.

References:
* [php/php-src#8805 php-src: #8805: finfo returns wrong mime type for woff/woff2 files]
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog]

Follow-up to [40124], [54508], [54509], [54724].

Props desrosj, jrf, costdev, SergeyBiryukov.
Merges [55462] to the 6.0 branch.
Fixes #56817.

git-svn-id: https://develop.svn.wordpress.org/branches/6.0@55497 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this issue Mar 9, 2023
As of PHP 8.1.12, which includes libmagic/file update to version 5.42, the expected mime type for WOFF files has changed to `font/woff`, so the type needs to be adjusted accordingly in `wp_check_filetype_and_ext()` tests.

References:
* [php/php-src#8805 php-src: #8805: finfo returns wrong mime type for woff/woff2 files]
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog]

Follow-up to [40124], [54508], [54509], [54724].

Props desrosj, jrf, costdev, SergeyBiryukov.
Merges [55462] to the 6.0 branch.
Fixes #56817.
Built from https://develop.svn.wordpress.org/branches/6.0@55497


git-svn-id: http://core.svn.wordpress.org/branches/6.0@55030 1a063a9b-81f0-0310-95a4-ce76da25c4cd
VenusPR added a commit to VenusPR/Wordpress_Richard that referenced this issue Mar 9, 2023
As of PHP 8.1.12, which includes libmagic/file update to version 5.42, the expected mime type for WOFF files has changed to `font/woff`, so the type needs to be adjusted accordingly in `wp_check_filetype_and_ext()` tests.

References:
* [php/php-src#8805 php-src: #8805: finfo returns wrong mime type for woff/woff2 files]
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog]

Follow-up to [40124], [54508], [54509], [54724].

Props costdev, SergeyBiryukov.
Fixes #56817.
Built from https://develop.svn.wordpress.org/trunk@55462


git-svn-id: http://core.svn.wordpress.org/trunk@54995 1a063a9b-81f0-0310-95a4-ce76da25c4cd
VenusPR added a commit to VenusPR/Wordpress_Richard that referenced this issue Mar 9, 2023
As of PHP 8.1.12, which includes libmagic/file update to version 5.42, the expected mime type for WOFF files has changed to `font/woff`, so the type needs to be adjusted accordingly in `wp_check_filetype_and_ext()` tests.

References:
* [php/php-src#8805 php-src: #8805: finfo returns wrong mime type for woff/woff2 files]
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog]

Follow-up to [40124], [54508], [54509], [54724].

Props costdev, SergeyBiryukov.
Merges [55462] to the 6.1 branch.
Fixes #56817.
Built from https://develop.svn.wordpress.org/branches/6.1@55463


git-svn-id: http://core.svn.wordpress.org/branches/6.1@54996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
hellofromtonya added a commit to hellofromtonya/wordpress-develop that referenced this issue Feb 14, 2024
Fixes a bug where fonts could not be installed in PHP 8.1.0 through 8.1.11 due to incorrect MIME type assignment.

While `WP_Font_Utils::get_allowed_font_mime_types()` conditionally sets the MIME type for woff and woff2, it incorrectly checks against PHP 8.1.0. The MIME type change did not occur until PHP 8.1.12.

References:

* PHP-src: finfo returns wrong mime type for woff/woff2 files php/php-src#8805
* PHP 8.1.12 changelog https://www.php.net/ChangeLog-8.php#8.1.12
* Tests: Adjust the expected mime type for WOFF fonts on PHP 8.1.12+ WordPress@5eefddf
* Gutenberg PR 59015 WordPress/gutenberg#59015

Props @costdev.
pento pushed a commit to WordPress/wordpress-develop that referenced this issue Feb 14, 2024
Fixes a bug where fonts could not be installed in PHP 8.1.0 through 8.1.11 due to incorrect MIME type assignment.

While `WP_Font_Utils::get_allowed_font_mime_types()` conditionally sets the MIME type for woff and woff2, it incorrectly checks against PHP 8.1.0. The MIME type change did not occur until PHP 8.1.12.

References:

* [php/php-src#8805 PHP-src: finfo returns wrong mime type for woff/woff2 files].
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog].
* Tests: Adjust the expected mime type for WOFF fonts on PHP 8.1.12+ [55463].
* [WordPress/gutenberg#59015 Gutenberg PR 59015].

Follow-up to [57539].

Props costdev, kafleg, hellofromTonya.
Fixes 60536.

git-svn-id: https://develop.svn.wordpress.org/trunk@57632 602fd350-edb4-49c9-b593-d223f7449a82
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this issue Feb 14, 2024
Fixes a bug where fonts could not be installed in PHP 8.1.0 through 8.1.11 due to incorrect MIME type assignment.

While `WP_Font_Utils::get_allowed_font_mime_types()` conditionally sets the MIME type for woff and woff2, it incorrectly checks against PHP 8.1.0. The MIME type change did not occur until PHP 8.1.12.

References:

* [php/php-src#8805 PHP-src: finfo returns wrong mime type for woff/woff2 files].
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog].
* Tests: Adjust the expected mime type for WOFF fonts on PHP 8.1.12+ [55463].
* [WordPress/gutenberg#59015 Gutenberg PR 59015].

Follow-up to [57539].

Props costdev, kafleg, hellofromTonya.
Fixes 60536.
Built from https://develop.svn.wordpress.org/trunk@57632


git-svn-id: https://core.svn.wordpress.org/trunk@57133 1a063a9b-81f0-0310-95a4-ce76da25c4cd
markjaquith pushed a commit to markjaquith/WordPress that referenced this issue Feb 14, 2024
Fixes a bug where fonts could not be installed in PHP 8.1.0 through 8.1.11 due to incorrect MIME type assignment.

While `WP_Font_Utils::get_allowed_font_mime_types()` conditionally sets the MIME type for woff and woff2, it incorrectly checks against PHP 8.1.0. The MIME type change did not occur until PHP 8.1.12.

References:

* [php/php-src#8805 PHP-src: finfo returns wrong mime type for woff/woff2 files].
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog].
* Tests: Adjust the expected mime type for WOFF fonts on PHP 8.1.12+ [55463].
* [WordPress/gutenberg#59015 Gutenberg PR 59015].

Follow-up to [57539].

Props costdev, kafleg, hellofromTonya.
Fixes 60536.
Built from https://develop.svn.wordpress.org/trunk@57632


git-svn-id: http://core.svn.wordpress.org/trunk@57133 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@weltling @adoy @kojot1234 @cmb69 and others