summaryrefslogtreecommitdiff
path: root/ext/phar/tests
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate passing null to non-nullable arg of internal functionNikita Popov2021-02-114-9/+9
| | | | | | | | | | | | | | | | | | | | | This deprecates passing null to non-nullable scale arguments of internal functions, with the eventual goal of making the behavior consistent with userland functions, where null is never accepted for non-nullable arguments. This change is expected to cause quite a lot of fallout. In most cases, calling code should be adjusted to avoid passing null. In some cases, PHP should be adjusted to make some function arguments nullable. I have already fixed a number of functions before landing this, but feel free to file a bug if you encounter a function that doesn't accept null, but probably should. (The rule of thumb for this to be applicable is that the function must have special behavior for 0 or "", which is distinct from the natural behavior of the parameter.) RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg Closes GH-6475.
* Make Phar $fileNotFoundScript nullableNikita Popov2021-02-0910-10/+10
| | | | | | | While "" is already treated the same way as absence, null is the logically correct default here. Making this one argument non-nullable is particularly pecular when considering that the preceding $alias and $index arguments are both nullable.
* Merge branch 'PHP-7.4' into PHP-8.0Christoph M. Becker2021-01-261-0/+60
|\ | | | | | | | | * PHP-7.4: Fix #70091: Phar does not mark UTF-8 filenames in ZIP archives
| * Fix #70091: Phar does not mark UTF-8 filenames in ZIP archivesChristoph M. Becker2021-01-261-0/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default encoding of filenames in a ZIP archive is IBM Code Page 437. Phar, however, only supports UTF-8 filenames. Therefore we have to mark filenames as being stored in UTF-8 by setting the general purpose bit 11 (the language encoding flag). The effect of not setting this bit for non ASCII filenames can be seen in popular tools like 7-Zip and UnZip, but not when extracting the archives via ext/phar (which is agnostic to the filename encoding), or via ext/zip (which guesses the encoding). Thus we add a somewhat brittle low-level test case. Closes GH-6630.
* | Merge branch 'PHP-7.4' into PHP-8.0Christoph M. Becker2021-01-251-1/+1
|\ \ | |/ | | | | | | * PHP-7.4: Fix #75850: Unclear error message wrt. __halt_compiler() w/o semicolon
| * Fix #75850: Unclear error message wrt. __halt_compiler() w/o semicolonChristoph M. Becker2021-01-251-1/+1
| | | | | | | | | | | | We add the failure reason to the error message. Closes GH-6638.
* | Merge branch 'PHP-7.4' into PHP-8.0Christoph M. Becker2021-01-211-0/+1
|\ \ | |/ | | | | | | * PHP-7.4: Add missing SKIPIF clause for recently introduced test case
| * Add missing SKIPIF clause for recently introduced test caseChristoph M. Becker2021-01-211-0/+1
| |
* | Merge branch 'PHP-7.4' into PHP-8.0Christoph M. Becker2021-01-202-0/+2
|\ \ | |/ | | | | | | * PHP-7.4: Add missing SKIPIF clauses to new test cases
| * Add missing SKIPIF clauses to new test casesChristoph M. Becker2021-01-202-0/+2
| |
* | Merge branch 'PHP-7.4' into PHP-8.0Christoph M. Becker2021-01-194-0/+90
|\ \ | |/ | | | | | | * PHP-7.4: Fix #69279: Compressed ZIP Phar extractTo() creates garbage files
| * Fix #69279: Compressed ZIP Phar extractTo() creates garbage filesChristoph M. Becker2021-01-194-0/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When extracting compressed files from an uncompressed Phar, we must not use the direct file pointer, but rather get an uncompressed file pointer. We also add a test to show that deflated and stored entries are properly extracted. This also fixes #79912, which appears to be a duplicate of #69279. Co-authored-by: Anna Filina <afilina@gmail.com> Closes GH-6599.
* | Add missing SKIPIF clause for require_hash.phptChristoph M. Becker2021-01-061-1/+4
| |
* | Merge branch 'PHP-7.4' into PHP-8.0Christoph M. Becker2021-01-054-2/+15
|\ \ | |/ | | | | | | * PHP-7.4: Fix #77565: Incorrect locator detection in ZIP-based phars
| * Fix #77565: Incorrect locator detection in ZIP-based pharsChristoph M. Becker2021-01-054-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We must not assume that the first end of central dir signature in a ZIP archive actually designates the end of central directory record, since the data in the archive may contain arbitrary byte patterns. Thus, we better search from the end of the data, what is also slightly more efficient. There is, however, no way to detect the end of central directory signature by searching from the end of the ZIP archive with absolute certainty, since the signature could be part of the trailing comment. To mitigate, we check that the comment length fits to the found position, but that might still not be the correct position in rare cases. Closes GH-6507.
* | Prevent double-free of Phar ZIP streamChristoph M. Becker2021-01-051-1/+1
| | | | | | | | | | | | | | We must not alias the closed stream to `phar_archive_data.fp`, and use PHAR_ZIP_FAIL() for consistency with the rest of this function. Closes GH-6578.
* | Fix #76929: zip-based phar does not respect phar.require_hashChristoph M. Becker2021-01-0422-0/+90
| | | | | | | | | | | | Based on the patch provided by david at bamsoftware. Closes GH-6517.
* | Merge branch 'PHP-7.4' into PHP-8.0Christoph M. Becker2020-12-151-0/+24
|\ \ | |/ | | | | | | * PHP-7.4: Fix #77322: PharData::addEmptyDir('/') Possible integer overflow
| * Fix #77322: PharData::addEmptyDir('/') Possible integer overflowChristoph M. Becker2020-12-151-0/+24
| | | | | | | | | | | | | | `phar_path_check()` already strips a leading slash, so we must not attempt to strip the trailing slash from an now empty directory name. Closes GH-6508.
* | Merge branch 'PHP-7.4' into PHP-8.0Christoph M. Becker2020-12-042-0/+13
|\ \ | |/ | | | | | | * PHP-7.4: Fix #75102: `PharData` says invalid checksum for valid tar
| * Fix #75102: `PharData` says invalid checksum for valid tarChristoph M. Becker2020-12-042-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | Apparently, there are broken tarballs out there which are actually in ustar format, but did not write the `ustar` marker. Since popular tar tools like GNU tar and 7zip have no issues dealing with such tarballs, Phar should also be more resilient. Thus, when the first checksum check of a tarball in (presumed) in old- style format fails, we check whether the checksum would be suitable for ustar format; if so, we treat the tarball as being in ustar format. Closes GH-6479.
* | Merge branch 'PHP-7.4' into PHP-8.0Christoph M. Becker2020-12-011-0/+30
|\ \ | |/ | | | | | | * PHP-7.4: Fix #73809: Phar Zip parse crash - mmap fail
| * Fix #73809: Phar Zip parse crash - mmap failChristoph M. Becker2020-12-011-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Phar signatures practically are of limited size; for the MD5 and SHA hashes the size is fixed (at most 64 bytes for SHA512); for OpenSSL public keys there is no size limit in theory, but "64 KiB ought to be good enough for anybody". So we check for that limit, to avoid fatal errors due to out of memory conditions. Since it is neither possible to have the signature compressed in the ZIP archive, nor is it possible to manually add a signature via Phar, we use ZipArchive to create a suitable archive for the test on the fly. Closes GH-6474.
* | Update ext/phar parameter namesNikita Popov2020-10-137-16/+16
| | | | | | | | Closes GH-6307.
* | Make Phar $format and $compression arguments nullableNikita Popov2020-10-081-2/+2
| | | | | | | | | | | | | | | | Rather than using Greg's birthday, use null to indicate that the existing format/compression should be retained. For the format simply using zero would be sufficient, but as the documentation explicitly says that NULL is allowed here, we may as well make that the truth.
* | Update ext/spl parameter namesNikita Popov2020-10-071-1/+1
| | | | | | | | Closes GH-6284.
* | Update ext/sockets parameter namesNikita Popov2020-10-061-1/+1
| | | | | | | | | | | | | | Also change $max_length to $length in a number of filesystem APIs, where our usage was inconsistent. Closes GH-6276.
* | Update ext/standard parameter namesNikita Popov2020-09-292-2/+2
| | | | | | | | Closes GH-6214.
* | Skip unnecessary unknown() framesNikita Popov2020-09-242-6/+4
| | | | | | | | | | | | | | | | | | | | Noticed this while working on attributes strict_types handling. We sometimes insert dummy frames internally, but I don't think these should show up in debug_backtrace output unless they're needed, either to display an include call or to preserve file/line information that would otherwise get lost. Closes GH-6195.
* | Run tidyNikita Popov2020-09-185-10/+10
| | | | | | | | | | This should fix most of the remaining issues with tabs and spaces being mixed in tests.
* | Improve error messages mentioning parameters instead of argumentsMáté Kocsis2020-09-093-6/+6
| | | | | | | | Closes GH-5999
* | Make null byte error a ValueErrorNikita Popov2020-09-089-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently we treat paths with null bytes as a TypeError, which is incorrect, and rather inconsistent, as we treat empty paths as ValueError. We do this because the error is generated by zpp and it's easier to always throw TypeError there. This changes the zpp implementation to throw a TypeError only if the type is actually wrong and throw ValueError for null bytes. The error message is also split accordingly, to be more precise. Closes GH-6094.
* | Fix UNKNOWN default values in various extensionsMáté Kocsis2020-09-071-1/+1
| | | | | | | | Closes GH-6075
* | Use the canonical order of types in array|string ZPP error messagesMáté Kocsis2020-09-041-1/+1
| |
* | Merge branch 'PHP-7.4' into masterChristoph M. Becker2020-09-031-0/+1
|\ \ | |/ | | | | | | * PHP-7.4: Skip test if A: drive exists
| * Merge branch 'PHP-7.3' into PHP-7.4Christoph M. Becker2020-09-031-0/+1
| |\ | | | | | | | | | | | | * PHP-7.3: Skip test if A: drive exists
| | * Skip test if A: drive existsChristoph M. Becker2020-09-031-0/+1
| | | | | | | | | | | | Otherwise the test case will fail for a very different reason.
| | * Merge branch 'PHP-7.2' into PHP-7.3Stanislav Malyshev2020-08-022-0/+14
| | |\ | | | | | | | | | | | | | | | | | | | | * PHP-7.2: Fix #79877: getimagesize function silently truncates after a null byte Fix #79797: Use of freed hash key in the phar_parse_zipfile function
| | | * Fix #79797: Use of freed hash key in the phar_parse_zipfile functionChristoph M. Becker2020-08-022-0/+14
| | | | | | | | | | | | | | | | We must not use heap memory after we freed it.
| | | * Fix bug #79082 - Files added to tar with Phar::buildFromIterator have ↵Stanislav Malyshev2020-02-163-0/+54
| | | | | | | | | | | | | | | | all-access permissions
| * | | Fix #79797: Use of freed hash key in the phar_parse_zipfile functionChristoph M. Becker2020-08-032-0/+14
| | | | | | | | | | | | | | | | We must not use heap memory after we freed it.
* | | | Promote warnings to exceptions in ext/pharMáté Kocsis2020-08-253-17/+48
| | | | | | | | | | | | | | | | Closes GH-6008
* | | | Skip bug70417.phpt if lsof output looks wrongNikita Popov2020-08-101-0/+3
| | | | | | | | | | | | | | | | | | | | On alpine lsof accepts -p but it doesn't actually do anything. Add a crude check for whether lsof looks like Linux lsof.
* | | | Fixup phar testNikita Popov2020-08-101-1/+0
| | | |
* | | | Add many missing closing PHP tags to testsMáté Kocsis2020-08-098-4/+5
| | | | | | | | | | | | | | | | Closes GH-5958
* | | | Add another round of missing parameter types to stubsMáté Kocsis2020-08-076-10/+19
| | | | | | | | | | | | | | | | Closes GH-5950
* | | | [RFC] Only unserialize Phar metadata when getMetadata() is calledTyson Andre2020-08-037-7/+261
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In other words, don't automatically unserialize when the magic phar:// stream wrappers are used. RFC: https://wiki.php.net/rfc/phar_stop_autoloading_metadata Also, change the signature from `getMetadata()` to `getMetadata(array $unserialize_options = [])`. Start throwing earlier if setMetadata() is called and serialization threw. See https://externals.io/message/110856 and https://bugs.php.net/bug.php?id=76774 This was refactored to add a phar_metadata_tracker for the following reasons: - The way to properly copy a zval was previously implicit and undocumented (e.g. is it a pointer to a raw string or an actual value) - Avoid unnecessary serialization and unserialization in the most common case - If a metadata value is serialized once while saving a new/modified phar file, this allows reusing the same serialized string. - Have as few ways to copy/clone/lazily parse metadata (etc.) as possible, so that code changes can be limited to only a few places in the future. - Performance is hopefully not a concern - copying a string should be faster than unserializing a value, and metadata should be rare in most cases. Remove unnecessary skip in a test(Compression's unused) Add additional assertions about usage of persistent phars Improve robustness of `Phar*->setMetadata()` - Add sanity checks for edge cases freeing metadata, when destructors or serializers modify the phar recursively. - Typical use cases of php have phar.readonly=1 and would not be affected. Closes GH-5855
* | | | Fix #79797: Use of freed hash key in the phar_parse_zipfile functionChristoph M. Becker2020-08-032-0/+14
| | | | | | | | | | | | | | | | We must not use heap memory after we freed it.
* | | | Review the usage of apostrophes in error messagesMáté Kocsis2020-07-101-1/+1
| | | | | | | | | | | | | | | | Closes GH-5590
* | | | Replace EXPECTF when possibleFabien Villepinte2020-06-291-1/+1
| | | | | | | | | | | | | | | | Closes GH-5779