Commit graph

26 commits

Author SHA1 Message Date
David Mudrák
6109e8b272 MDL-70631 files: Replace hard-coded value with FL_ENC_RAW constant
This is not related to the issue but I noticed it while trying to debug
it.

Back when this line was introduced in 9c140a681e, the ZipArchive had
not yet exposed this flag as a constant. It was added later with PHP
7.0.8 and we can switch to using it now.
2021-02-03 16:06:39 +01:00
David Mudrák
b227b6ea45 MDL-70631 files: Fix performance of zip_packer::extract_to_pathname()
The original implementation was based on ZipArchive::getStream() which
turns out to be very slow and if the archive contains many files, the
unzipping performance is very slow.

The patch changes the implementation to use ZipArchive::extractTo()
unless the extracted entry path contains a folder name ending with dot
(such as some/path./to/file.txt). There is a known upstream bug in the
PHP ZIP extension #77214 (also #74619 and #69477) so that we fall back
to keep using the stream in those cases.
2021-02-03 16:06:39 +01:00
Julien Boulen
7d918bc693 MDL-68137 core_files: replace consecutive dots in filename by single dot 2020-04-28 11:29:35 +02:00
Vladimir Zhirov
ff2dab4566 MDL-59005 resource: fixed zip extraction for filenames in CP-1251/CP-866 2017-06-19 08:50:23 +08:00
Russell Smith
261bfabc6f MDL-54916 filestorage: Only write empty zip on change.
In some cases we may inspect an empty zip file. If we do open
an empty zip file, check that it changed before we attempt to write
it to disk.  It may be the case that we were reading the file from
a location that we don't have write access to.
2016-10-25 14:10:36 +11:00
Eloy Lafuente (stronk7)
70ae75674d MDL-51863 packer: ensure empty zip files behavior remains consistent
With PHP bug #70322 fixed, ZipArchive::close() did start returning false
and throwing PHP Warnings with recent PHP versions (5.6.14 and up).
Previously (5.6.13 verified) it was returning true, and false in older
versions (5.4.x verified).

This change does silent the 2 "hacky" calls to close() that we perform
in core leaving the 3rd one (used for files having files) unmodified.

A new unit test has been created to cover the close() behavior, ideally
supporting both old and new PHP versions without harcoding any PHP
version.

Note that we don't use to rely much on results coming from close(), and
that's a good thing given the buggy behavior commented above. This just
keeps empty zips working like they were before.
2015-10-26 21:16:54 +01:00
Mitsuhiro Yoshida
6396b58e15 MDL-49259 lib: Fix for unzipped Japanese filename character corruption 2015-02-25 23:29:02 +09:00
Petr Škoda
9c140a681e MDL-44300 force PHP 5.6.x to return raw file names for our own guessing 2014-03-17 12:34:02 +13:00
sam marshall
71ab7e512b MDL-41151 Files: Zip packer should have way to indicate progress 2013-09-05 16:41:57 +01:00
Petr Škoda
2f1e464a88 MDL-40438 migrate all collatorlib:: and textlib:: uses 2013-08-06 21:04:35 +02:00
Petr Škoda
e8875a86be MDL-40900 do not use 32bit unsigned integers
32bit PHP and any Windows PHP breaks otherwise.
2013-07-28 13:10:57 +02:00
Paul Nicholls
f384ce26c0 MDL-39339 - zip_archive should ignore system files
zip_archive should ignore OSX system files (__MACOSX, .DS_Store) and
Windows thumbnail cache files (Thumbs.db), to avoid issues and confusion.
2013-05-30 09:23:35 +12:00
Petr Škoda
231b022777 MDL-37407 add support for zh_cn unicode unzip 2013-01-25 15:55:52 +01:00
Petr Škoda
009f190c69 MDL-37429 hack around zip limitations in PHP versions < 5.3.10 2013-01-17 16:48:29 +01:00
Petr Škoda
01b4040a27 MDL-37429 zipping improvements
Changes:
* zip_packer can create empty zip archives
* new option to ignore problematic files when creating archive
* detection of non-existent files
* debugging messages for opening of faulty zip archives
* coding style improvements
* no PHP 5.2 hacks
* more unit tests
2013-01-12 14:58:26 +01:00
Vadim Dvorovenko
697ade2850 MDL-32639 files: Removing '0' start folder in archives created with filemanager 2012-12-10 12:30:29 +08:00
Petr Škoda
177ffd37ff MDL-35795 add fallback for DOS/Windows non-utf8 zip archive unzipping 2012-10-06 10:02:11 +02:00
Petr Škoda
00f744d2b1 MDL-33753 fix sloppy refactoring regression in zip tweaking 2012-07-11 11:10:19 +02:00
Petr Skoda
6fb8ae95f5 MDL-33753 support utf-8 filename unzipping 2012-07-06 08:03:38 +02:00
Petr Skoda
79c966cf21 MDL-33710, MDL-33710 add utf-8 flag to all zip files created in moodle and unzip from storage fix 2012-07-06 08:02:42 +02:00
Dongsheng Cai
d2b7803e5a MDL-30973 Files API, check and update DocBlock 2012-02-15 12:48:57 +08:00
Petr Skoda
ac6f1a82f9 MDL-24321 switching to stdClass 2010-09-21 07:57:42 +00:00
Petr Skoda
8a680500c6 fixed phpdocs and incorrect exception names 2010-09-18 10:31:31 +00:00
Petr Skoda
05f2d18ba2 MDL-18431 use of ZIPARCHIVE::OVERWRITE changed in 5.2.8 - credit goes to Dan Marsden 2010-09-10 21:19:31 +00:00
Petr Skoda
c311889cc0 MDL-18431 use of ZIPARCHIVE::OVERWRITE changed in 5.2.8 2010-09-10 21:18:31 +00:00
Petr Skoda
64f93798d4 MDL-22950 adding new component column to the files table, unfortunately this change requires changes in all 2.0dev code, please review all custom code that was already upgraded to 2.0; fixing multiple problems and regressions in mod/assignment 2010-07-03 13:37:13 +00:00
Renamed from lib/packer/zip_archive.php (Browse further)