Font Library: Refactors the upload handler in order to check if files being uploaded are valid font files.#59648
Conversation
Fixes: #59578 Refactors the upload handler in order to check if files being uploaded are valid font files.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +355 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
peterwilsoncc
left a comment
There was a problem hiding this comment.
This looks good to me and test well.
I've got a few nitpicks in to match the documentation standards and add a return type to the docblock.
Pre-approving as the code is LGTM.
…odal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
…odal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
…odal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
…odal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
…odal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
…odal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
…odal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
…odal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
There was a problem hiding this comment.
This works as advertised: invalid font files raise an error notice, and valid font files continue to upload as expected.
Because of that, I approved the PR. Still, I think we could simplify the code a little by doing this: https://github.com/WordPress/gutenberg/pull/59648/files#r1516698107
LGTM
|
I broken the linting. I'll fix that shortly. |
|
Proposing for inclusion in WP 6.5 during RC period because this is a bug in the critical upload path for the Font Libray feature. It seems to have been identified during the RC testing phase. |
… being uploaded are valid font files. (#59648) * Font Library: check if file upload is valid font Fixes: #59578 Refactors the upload handler in order to check if files being uploaded are valid font files. * make sure error message is relevant * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * error message syntax * use WordPress yoda condition * Respect string freeze * Fix lint --------- Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> Co-authored-by: Dave Smith <getdavemail@gmail.com>
|
I just manually cherry-picked this PR to the pick/wp-65-rc-2 branch to get it included in the next release |
… being uploaded are valid font files. (#59648) * Font Library: check if file upload is valid font Fixes: #59578 Refactors the upload handler in order to check if files being uploaded are valid font files. * make sure error message is relevant * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * error message syntax * use WordPress yoda condition * Respect string freeze * Fix lint --------- Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> Co-authored-by: Dave Smith <getdavemail@gmail.com>
… being uploaded are valid font files. (WordPress#59648) * Font Library: check if file upload is valid font Fixes: WordPress#59578 Refactors the upload handler in order to check if files being uploaded are valid font files. * make sure error message is relevant * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * Update packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> * error message syntax * use WordPress yoda condition * Respect string freeze * Fix lint --------- Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> Co-authored-by: Dave Smith <getdavemail@gmail.com>

What?
Refactors the upload handler in order to check if files being uploaded are valid font files.
Why?
Fixes: #59578
Uploading invalid font files would cause the uploader to crash due to lack of error handling.
Testing Instructions