From 2ac96bcd07ca615216cedbd855d641fca65853e5 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Mon, 5 Feb 2024 22:21:35 +0000 Subject: Upload: Fallback to `PclZip` to validate ZIP file uploads. `ZipArchive` can fail to validate ZIP files correctly and report valid files as invalid. This introduces a fallback to `PclZip` to check validity of files if `ZipArchive` fails them. This introduces the new function `wp_zip_file_is_valid()` to validate archives. Follow up to [57388]. Props audunmb, azaozz, britner, cdevroe, colorful-tones, costdev, courane01, endymion00, feastdesignco, halounsbury, jeffpaul, johnbillion, jorbin, jsandtro, karinclimber, kevincoleman, koesper, maartenbelmans, mathewemoore, melcarthus, mujuonly, nerdpressteam, olegfuture, otto42, peterwilsoncc, room34, sayful, schutzsmith, stephencronin, svitlana41319, swissspidy, tnolte, tobiasbg, vikram6, welaunchio. Fixes #60398. git-svn-id: https://develop.svn.wordpress.org/trunk@57537 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/data/filesystem/_source-license | 33 +++++++++++++++++++++ tests/phpunit/data/filesystem/archive-comment.zip | Bin 0 -> 468 bytes tests/phpunit/data/filesystem/archive-cp866.zip | Bin 0 -> 163 bytes .../data/filesystem/archive-directory-entry.zip | Bin 0 -> 2480 bytes .../phpunit/data/filesystem/archive-encrypted.zip | Bin 0 -> 1692 bytes .../phpunit/data/filesystem/archive-flags-set.zip | Bin 0 -> 1636 bytes tests/phpunit/data/filesystem/archive-gnome.zip | Bin 0 -> 1193 bytes .../phpunit/data/filesystem/archive-invalid-ext.md | 7 +++++ tests/phpunit/data/filesystem/archive-invalid.zip | Bin 0 -> 1100 bytes tests/phpunit/data/filesystem/archive-large.zip | Bin 0 -> 5210464 bytes tests/phpunit/data/filesystem/archive-macos.zip | Bin 0 -> 2090 bytes .../data/filesystem/archive-ubuntu-nautilus.zip | Bin 0 -> 798 bytes .../data/filesystem/archive-uncompressed.zip | Bin 0 -> 489 bytes tests/phpunit/data/filesystem/archive.crx | Bin 0 -> 2202 bytes 14 files changed, 40 insertions(+) create mode 100644 tests/phpunit/data/filesystem/_source-license create mode 100644 tests/phpunit/data/filesystem/archive-comment.zip create mode 100644 tests/phpunit/data/filesystem/archive-cp866.zip create mode 100644 tests/phpunit/data/filesystem/archive-directory-entry.zip create mode 100644 tests/phpunit/data/filesystem/archive-encrypted.zip create mode 100644 tests/phpunit/data/filesystem/archive-flags-set.zip create mode 100644 tests/phpunit/data/filesystem/archive-gnome.zip create mode 100644 tests/phpunit/data/filesystem/archive-invalid-ext.md create mode 100644 tests/phpunit/data/filesystem/archive-invalid.zip create mode 100644 tests/phpunit/data/filesystem/archive-large.zip create mode 100644 tests/phpunit/data/filesystem/archive-macos.zip create mode 100644 tests/phpunit/data/filesystem/archive-ubuntu-nautilus.zip create mode 100644 tests/phpunit/data/filesystem/archive-uncompressed.zip create mode 100644 tests/phpunit/data/filesystem/archive.crx (limited to 'tests/phpunit/data/filesystem') diff --git a/tests/phpunit/data/filesystem/_source-license b/tests/phpunit/data/filesystem/_source-license new file mode 100644 index 0000000000..580a1492a4 --- /dev/null +++ b/tests/phpunit/data/filesystem/_source-license @@ -0,0 +1,33 @@ +The following files were sourced from https://github.com/ZJONSSON/node-unzipper a fork of https://github.com/EvanOxfeld/node-unzip + +* archive-comment.zip +* archive-cp866.zip +* archive-directory-entry.zip +* archive-encrypted.zip +* archive-flags-set.zip +* archive-invalid.zip +* archive-large.zip +* archive-uncompressed.zip +* archive.crx + +Copyright (c) 2012 - 2013 Near Infinity Corporation +Copyright (c) 2016 - 2024 Ziggy Jonsson (ziggy.jonsson.nyc@gmail.com) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tests/phpunit/data/filesystem/archive-comment.zip b/tests/phpunit/data/filesystem/archive-comment.zip new file mode 100644 index 0000000000..14a862f1f1 Binary files /dev/null and b/tests/phpunit/data/filesystem/archive-comment.zip differ diff --git a/tests/phpunit/data/filesystem/archive-cp866.zip b/tests/phpunit/data/filesystem/archive-cp866.zip new file mode 100644 index 0000000000..04bd3c9372 Binary files /dev/null and b/tests/phpunit/data/filesystem/archive-cp866.zip differ diff --git a/tests/phpunit/data/filesystem/archive-directory-entry.zip b/tests/phpunit/data/filesystem/archive-directory-entry.zip new file mode 100644 index 0000000000..e81a6aa7e0 Binary files /dev/null and b/tests/phpunit/data/filesystem/archive-directory-entry.zip differ diff --git a/tests/phpunit/data/filesystem/archive-encrypted.zip b/tests/phpunit/data/filesystem/archive-encrypted.zip new file mode 100644 index 0000000000..fd58fb4f1d Binary files /dev/null and b/tests/phpunit/data/filesystem/archive-encrypted.zip differ diff --git a/tests/phpunit/data/filesystem/archive-flags-set.zip b/tests/phpunit/data/filesystem/archive-flags-set.zip new file mode 100644 index 0000000000..015ce233c4 Binary files /dev/null and b/tests/phpunit/data/filesystem/archive-flags-set.zip differ diff --git a/tests/phpunit/data/filesystem/archive-gnome.zip b/tests/phpunit/data/filesystem/archive-gnome.zip new file mode 100644 index 0000000000..0f1fc181ea Binary files /dev/null and b/tests/phpunit/data/filesystem/archive-gnome.zip differ diff --git a/tests/phpunit/data/filesystem/archive-invalid-ext.md b/tests/phpunit/data/filesystem/archive-invalid-ext.md new file mode 100644 index 0000000000..1531b03435 --- /dev/null +++ b/tests/phpunit/data/filesystem/archive-invalid-ext.md @@ -0,0 +1,7 @@ +# Shucked + +Shucked is a 2022 musical with music and lyrics by Brandy Clark and Shane McAnally, and a book by Robert Horn. The Broadway production began previews at the Nederlander Theatre on March 8, 2023, before opening on April 4. The show received positive reviews and went on to receive nine nominations at the 76th Tony Awards, including Best Musical. Cast member Alex Newell became one of the first two openly non-binary performers to be nominated for and win a Tony Award, with their win for Best Featured Actor in a Musical. + +A U.S. tour, West End production, and feature film adaptation are currently planned. + +From Wikipedia (https://en.wikipedia.org/wiki/Shucked) under Creative Commons Attribution CC-BY-SA 3.0 (https://creativecommons.org/licenses/by-sa/3.0/legalcode) diff --git a/tests/phpunit/data/filesystem/archive-invalid.zip b/tests/phpunit/data/filesystem/archive-invalid.zip new file mode 100644 index 0000000000..d13ba6b7ff Binary files /dev/null and b/tests/phpunit/data/filesystem/archive-invalid.zip differ diff --git a/tests/phpunit/data/filesystem/archive-large.zip b/tests/phpunit/data/filesystem/archive-large.zip new file mode 100644 index 0000000000..57c1635fdf Binary files /dev/null and b/tests/phpunit/data/filesystem/archive-large.zip differ diff --git a/tests/phpunit/data/filesystem/archive-macos.zip b/tests/phpunit/data/filesystem/archive-macos.zip new file mode 100644 index 0000000000..a5493f9fa0 Binary files /dev/null and b/tests/phpunit/data/filesystem/archive-macos.zip differ diff --git a/tests/phpunit/data/filesystem/archive-ubuntu-nautilus.zip b/tests/phpunit/data/filesystem/archive-ubuntu-nautilus.zip new file mode 100644 index 0000000000..a1d65d1771 Binary files /dev/null and b/tests/phpunit/data/filesystem/archive-ubuntu-nautilus.zip differ diff --git a/tests/phpunit/data/filesystem/archive-uncompressed.zip b/tests/phpunit/data/filesystem/archive-uncompressed.zip new file mode 100644 index 0000000000..2d3626d6b6 Binary files /dev/null and b/tests/phpunit/data/filesystem/archive-uncompressed.zip differ diff --git a/tests/phpunit/data/filesystem/archive.crx b/tests/phpunit/data/filesystem/archive.crx new file mode 100644 index 0000000000..c07b21c6c1 Binary files /dev/null and b/tests/phpunit/data/filesystem/archive.crx differ -- cgit v1.2.3