Commit Graph

565 Commits

Author SHA1 Message Date
Greg Beaver
a919e2f858 fix serious logic error and potential security issue with phar_compiled_file and
phar_find_in_include_path.  We were allowing data-based phars to be executed, and actually marking phar-based phar archives
without '.phar' in the name as data-based phars, which would allow modifying them even if phar.readonly=0.  Add test for this sinister case
2008-05-08 00:49:37 +00:00
Greg Beaver
f134a909c3 optimize phar filename extension detection to first search through known phars. This eliminates several stat/realpath calls for archives with lots of files 2008-05-07 17:24:22 +00:00
Greg Beaver
549bf83bd1 [DOC]
remove phar.extract_list
remove Phar::getExtractList()
2008-05-07 05:38:31 +00:00
Greg Beaver
f8db86b008 remove APC fanciness - this was causing non-caching of some files include()d inside a phar archive 2008-05-07 05:13:41 +00:00
Greg Beaver
5ba8ca70a4 fix alias overloading handling for archives that are not in use 2008-05-06 21:14:53 +00:00
Steph Fox
8a970147ad - Allow setStub() to continue working
- Fix tests broken by earlier commit
2008-04-29 12:26:58 +00:00
Steph Fox
8559a2dbde - Prevent phars with empty manifests flushing to disk
- This would've fixed that test... removing clean section

@Greg: I commented out the call that breaks the Windows build, pending a decision about its future.
2008-04-29 12:06:54 +00:00
Greg Beaver
ee1273af7a remove hack introduced because of broken usage of php_resolve_path instead of zend_resolve_path 2008-04-28 22:41:20 +00:00
Greg Beaver
fbb2e8ce60 more fixes for PHAR_G(cwd) 2008-04-28 06:03:33 +00:00
Greg Beaver
fd9bf92ac6 fix out-of-bounds read potential by replacing strstr with a custom strnstr 2008-04-27 07:20:02 +00:00
Greg Beaver
5bf3d1d362 fix invalid free 2008-04-27 07:04:56 +00:00
Greg Beaver
94846549f5 fix APC compile hook interception, now APC actually caches files 2008-04-26 23:16:49 +00:00
Steph Fox
21584ed029 - kill a couple of (release build) MS compiler warnings 2008-04-24 16:59:23 +00:00
Greg Beaver
24d83fa7f8 fix break when uncompressed files are re-saved, fixes phar_copy.phpt test 2008-04-24 04:56:22 +00:00
Greg Beaver
3d890f09a8 fix extension detection for executable=2 2008-04-23 18:22:09 +00:00
Greg Beaver
c034683550 new test for Phar::isValidPharFilename. Fix Phar::isValidPharFilename. Fix extension detection for all cases 2008-04-23 18:11:20 +00:00
Greg Beaver
5a4a54f64b remove unused code 2008-04-21 16:51:26 +00:00
Greg Beaver
aaf6101928 another refactoring to combine an error and improve code coverage as a side effect 2008-04-21 16:50:18 +00:00
Greg Beaver
32f2eeea47 minor re-factoring reduces code lines for an error (and evilly increases code coverage at gcov ;) 2008-04-21 16:46:01 +00:00
Greg Beaver
69f74c5c80 minor re-factoring reduces code lines for an error (and evilly increases code coverage at gcov ;) 2008-04-21 16:42:53 +00:00
Greg Beaver
3d858f4aa9 implement symbolic link support within a tar-based phar archive
this also resulted in a major fix for mounted directories, which were recycling the 'link' field which
could cause stupid conflicts with actual links, so move that to new 'tmp' field.
2008-04-21 06:17:51 +00:00
Greg Beaver
027180d6ee new test for bad checksum, fix tar.c to catch tar archives with a corrupted first entry, fix memleak on bad checksum 2008-04-20 17:28:54 +00:00
Greg Beaver
ab45c16a61 fix all but 1 test on windows (yay) 2008-04-20 04:19:13 +00:00
Greg Beaver
54540385b8 fix a couple more tests on windows 2008-04-20 04:10:51 +00:00
Greg Beaver
95fc6451f0 fix 98 of 105 failing tests on windows (real progress now) 2008-04-20 00:24:01 +00:00
Greg Beaver
9035dc059a fix 3 failing tests out of 108 on windows (whoop-de-doo) 2008-04-19 17:57:24 +00:00
Greg Beaver
ef0139c866 fix ZTS build 2008-04-19 17:24:41 +00:00
Greg Beaver
c4f502fae0 COMPLETELY rework filename extension detection. Now the only requirements are:
1 - executable phars must contain '.phar' in the filename
2 - non-executable phars must not contain '.phar' and must have an extension of at least 1 character

In addition, phar filenames must exist if opened for read, and the directory containing the phar must exist if opened for creation
if opened for creation, the file must not already exist
[DOC]
2008-04-18 04:13:13 +00:00
Greg Beaver
8c4477cde5 fix segfault in meta-data parsing of zip archives 2008-04-16 04:15:08 +00:00
Greg Beaver
dc837b5f53 rename is_zip parameter of phar_parse_metadata to more accurately reflect what it is 2008-04-16 04:01:33 +00:00
Greg Beaver
6387155b3d add another test for alias overloading and make sure we disallow it when passed in constructor 2008-04-16 03:42:29 +00:00
Greg Beaver
6c0564c721 increase code coverage for phpinfo(), rework CLI phpinfo for phar.extract_list to be legible 2008-04-16 03:26:20 +00:00
Greg Beaver
77b6ed3861 further big-endian systems fixes for zip 2008-04-15 19:16:47 +00:00
Greg Beaver
1a2ac90cde truly enable APC in phar 2008-04-15 13:52:02 +00:00
Greg Beaver
9e33e0cc5b add support for proper APC caching 2008-04-15 04:56:34 +00:00
Greg Beaver
2277396fe3 fix edge case where a new phar is created via mkdir(), add to dir.phpt test 2008-04-14 15:21:41 +00:00
Greg Beaver
b8865a63ae another attempt at fixing mac OS X compile, remove unused obsolete code 2008-04-14 04:47:34 +00:00
Greg Beaver
1c3097fcbe make built-in SplFileInfo->isWriteable() work for PharFileInfo as well, by ensuring phar->is_writeable is set/reset when phar.readonly is changed 2008-04-10 03:12:08 +00:00
Marcus Boerger
5b3560f069 - Ifdef out code that has if(0) and doesn't compile anyway 2008-03-27 12:54:23 +00:00
Greg Beaver
a090d45251 fix build on PHP 5.2, prepare release of 2.0.0a2 2008-03-27 06:38:53 +00:00
Marcus Boerger
7202434956 - Add documentation 2008-03-24 12:53:28 +00:00
Greg Beaver
1bda8cf708 a subtle plea for help to Marcus... 2008-03-24 03:05:24 +00:00
Greg Beaver
2e9fca4f0b fix read/write for PharData object, update tests to current API 2008-03-24 03:01:31 +00:00
Marcus Boerger
69c71f703e - Add .cvsignore 2008-03-23 16:51:52 +00:00
Greg Beaver
27ca45f898 don't disallow opening .tar/.zip files as Phar object if readonly is disabled, the whole idea is to be able to
add crap including an automatic stub or explicit stub
2008-03-23 06:59:59 +00:00
Greg Beaver
eea82226c1 fix potential segfault by misuse of phar_find_in_include_path 2008-03-23 05:39:58 +00:00
Greg Beaver
6cef8da201 move all blah++ to ++blah where possible for those with crapass compilers 2008-03-22 22:11:49 +00:00
Greg Beaver
01e5bbbaf5 fix memleak in php 5.2, simplify code slightly 2008-03-22 21:54:55 +00:00
Steph Fox
c0619c6523 Make versioning more standard 2008-03-22 17:09:24 +00:00
Marcus Boerger
1b286e1475 - If multiple possible exts are found use the first one.
This fixes an issue with: phar.phar info -f install-pear-nozlib.phar
  because that archive contains a .tar file
2008-03-22 00:15:45 +00:00
Marcus Boerger
e08556eb2e - Constify 2008-03-22 00:11:43 +00:00
Greg Beaver
d02dff1363 save work - sandbox is completely f**ed up, have to rm -rf and start again
This *SHOULD* fix issues, but I can't get run-tests to work reliably to be absolutely sure
2008-03-20 23:59:07 +00:00
Marcus Boerger
a1cbab9142 - Rewrite scanner to be based on re2c instead of flex
The full patch is available as:
  http://php.net/~helly/php-re2c-5.3-20080316.diff.txt
  This is against php-re2c repository version 98
  An older patch against version 97 is available under:
  http://php.net/~helly/php-re2c-97-20080316.diff.txt
2008-03-16 21:06:54 +00:00
Antony Dovgal
983ff657ba fix zts build 2008-03-13 09:57:49 +00:00
Greg Beaver
0262e844c4 implement full support and usage of phar stream in include_path, for both 5.2 and 5.3.
5.3 code expects the proposed patch for stream wrapper in include_path to be committed
5.2 code only supports phar stream wrapper in include_path.
this is a 2-step process.  After this, more magic, particularly in funcinterceptors.c will be
converted to use phar_resolve_path, which is far safer than the current implementation.

this needs windows and 5.2 testing unix/windows
2008-03-12 03:55:12 +00:00
Steph Fox
8343d7c139 - A bit more work on PharData creation/conversion.
- If readonly=0, why not $phardata->convertToPhar()?
- Known issue with directories creating 'as-file' copies within the archive (all formats)
@Greg/Marcus/Tony: This passes all tests on my box, 5.2/5.3/release_ts/debug_ts, and I can't find any more memleaks. Obviously this is too good to be true, so if conversion is still messy elsewhere please feel free to fix, or bug and assign to me.
2008-03-03 08:41:15 +00:00
Steph Fox
001ffec19f Initial support for PharData object.
Note: two tests currently fail. IMHO we should be throwing E_ERROR on encountering a corrupted archive, not trying to throw a trail of exceptions...
New tests still to be written, not all functionality is in place yet.
2008-02-27 21:34:26 +00:00
Greg Beaver
ec7f89fe79 implement Phar::mount() for directories, add test
# opendir not yet implemented for mounted directories
2008-02-25 04:23:36 +00:00
Steph Fox
8513db73bb A bunch of stuff to do with filename conversion. Hopefully it won't sink the ship. 2008-02-24 22:29:06 +00:00
Greg Beaver
f6862d4a33 fix unfreed value found in tempmanifest1.phpt 2008-02-23 19:44:51 +00:00
Greg Beaver
b3a266fca8 fix double error (this fixes frontcontroller22.phpt) 2008-02-23 19:26:18 +00:00
Steph Fox
6cc2426ff1 A much better solution for setDefaultStub(). The convertTo*() fixes should be trivial now. 2008-02-21 00:24:38 +00:00
Steph Fox
d8bebd7259 Implement $phar->setDefaultStub()
Note that Phar::createDefaultStub() still exists at this point
2008-02-20 19:22:12 +00:00
Steph Fox
7bb00d024e Allow createDefaultStub() to accept 0, 1 or 2 parameters. Default for both CLI and web is 'index.php'.
@Greg: this breaks a handful of tests due to the change in stub.h - will fix in a bit. The only one that's interesting is you can't do strlen(Phar::createDefaultStub()) and expect anything other than an exception now.
2008-02-18 21:45:02 +00:00
Steph Fox
335e57e443 Fix ZTS build (again), kill unused var 2008-02-18 04:51:04 +00:00
Greg Beaver
ba9fcf62fc add initial support for hashing mounted directories. Actual matching of mounted directories is not yet supported. 2008-02-18 04:45:42 +00:00
Steph Fox
87626d56d2 Fix ZTS build *nicely* 2008-02-18 04:42:04 +00:00
Greg Beaver
6798dc44ed add Phar::mount() to manually mount a file or directory
# TODO: implement directory mounting.  Involves scanning paths that are not exact matches for a partial match.
# this also means maintaining a per-phar hash of mounted directories for quick matching
2008-02-18 04:32:50 +00:00
Greg Beaver
9c62ef1124 add externally parsed files to temporary manifest (this will be made
optional and must be explicitly enabled per-phar)
2008-02-18 03:37:51 +00:00
Greg Beaver
f72ce59e95 remove refcount hack to workaround zlib memleak fixed in zlib
intercepted file functions now fall through if the file is not found in the phar, this allows access to external libraries
actually use include_path for locating files for inclusion and in file_get_contents/fopen when include_path is requested.
This allows applications like Zend Framework MVC implementation to function properly
2008-02-13 15:00:31 +00:00
Greg Beaver
3234e78ca1 fix remaining broken tests broken by the addition of phar->fp closing 2008-02-12 05:28:06 +00:00
Greg Beaver
ba002c5b9c revert last commit to phar_object.c
fix open file pointers issue on windows
2008-02-11 17:13:18 +00:00
Greg Beaver
d659ce7a0c fix windows pathname issues 2008-02-11 07:33:20 +00:00
Greg Beaver
d388ec586f move creation of phar archive to the point at which it is committed to disk, instead of
at the moment it is attempted access. (making some real progress now, all tests pass on unix)
2008-02-11 06:53:56 +00:00
Greg Beaver
78e8eb3900 major refactoring of internal handling of aliases.
1) rename is_explicit_alias to is_temporary_alias for clarity and flip the value
2) fix setAlias so that it sets a permanent to-be-saved alias, and restores the old one on error
3) fix Phar constructor to work with sub-directories in RecursiveDirectoryIterator
2008-02-11 06:46:44 +00:00
Greg Beaver
3874e12ee5 fix 5.2 build 2008-02-11 04:48:58 +00:00
Greg Beaver
15410a4f66 make maximum manifest size 100MB for phar archives, simple apps are hitting the 1 MB limit quite easily. 2008-02-08 05:56:26 +00:00
Greg Beaver
5b5c86df9f better fix for double free - ensure that SEPARATE_ZVAL() inside
zlib_filter.c actually separates the zval, then we can zval_dtor() it
properly
2008-02-08 05:41:59 +00:00
Greg Beaver
fa7a1779a1 remove unnecessary INIT_ZVAL(filterparams) that causes unfreed value 2008-02-08 05:05:13 +00:00
Greg Beaver
e3c64bd53b fix memory leaks. There are some leaks in libz that I can't fix, but none triggered in the current tests 2008-02-08 04:26:41 +00:00
Antony Dovgal
a04bcdfcec remove old code leftover causing problems 2008-02-07 08:45:43 +00:00
Antony Dovgal
97c3dbaf56 this string should be freed later since path == free_path 2008-02-01 11:25:11 +00:00
Steph Fox
9fd5c0b438 - Moved phar_unixify_path_separators() to a single central point
- The last two VC 6 compiler warnings gone. Please test under *nix.
2008-01-28 14:39:17 +00:00
Greg Beaver
6cdabede4c remove ext/zip dependency entirely, write better native zip support
re-organize, create util.c, move entry_info/archive_data/entry_data access methods to this file
refactor entry->fp, now this is abstracted with phar_get_efp() and phar_seek_efp(), fixes all weird dependency issues
permanently solve the "millions of file pointers" issue for read access.  All compressed files are read into a single
temporary stream, and their constraints are controlled by the entry->fp abstraction

Improvements in this zip implementation over ext/zip:
 * full read/write support for bzip2 compressed files
 * much more efficient access for accessing only a few files within large zip files, as crc/header validation is
   done just-in-time
 * full stream support for opendir/rename/rmdir/mkdir as well as all of the other stream funcs
 * full support for setting file perms via Phar::chmod(), stored as zip-standard extra field
 * no problem with large zips and many open file pointers

# TODO: add big-endian system support for tar/zip file format headers, otherwise the implementation is complete
# TODO: test on windows and fix any windows-specific issues
# TODO: verify zips created work with unzip/winzip/windows explorer and so on
2008-01-28 08:52:08 +00:00
Greg Beaver
f51bf6118c fix tests to match CVS 2008-01-22 05:26:38 +00:00
Greg Beaver
117f5e2639 add web-based support for default stub, now phars written with webPhar() will work
out of the box regardless of server configuration with phar file format
split up stub.h strings into 2046 byte chunks because MS VC 6 is friggin stupid
2008-01-20 00:49:45 +00:00
Greg Beaver
a5358c0725 bump API version if the created phar has directories in it, so that it won't load with older phar versions 2008-01-19 18:30:30 +00:00
Greg Beaver
d583fae0cc add Phar::createDefaultStub(), which can take as an argument the filename
that should be loaded as a "bootstrap" for the phar archive
2008-01-19 04:26:22 +00:00
Greg Beaver
7540adf058 major improvement:
the new default stub allows creation of phars that run identically
1) with Phar extension
2) without Phar extension
3) extracted to disk from the phar
this makes the default phar format quite interesting as it eliminates the only drawback of the extension
2008-01-18 05:42:16 +00:00
Greg Beaver
109cbc9f50 add needed define back into config.w32, make zip required mod on win32, remove lib/.cvsignore 2008-01-18 00:11:37 +00:00
Greg Beaver
e4c02a6b96 do fancy-shmancy zip dependency validation because ZEND_MOD_OPTIONAL_EX doesn't do any version validation 2008-01-17 05:52:18 +00:00
Greg Beaver
9a59e60657 remove HAVE_ZIP defines just as we removed HAVE_BZ2 defines and for the same reason
update outdated description of phar in config.m4
make zip extension mandatory on windows for compiling purposes
2008-01-17 03:59:07 +00:00
Greg Beaver
a3718dcfa3 no need to use conditional defines for bz2, we don't call it except indirectly through stream wrappers.
After removing HAVE_BZ2 conditionals, phar works even if bz2 is not present on installation through pecl
2008-01-17 03:48:29 +00:00
Greg Beaver
535865e908 give up on gpg signing because of non-existent windows support for gpg signing lib 2008-01-17 03:19:44 +00:00
Greg Beaver
d1eda9c8ac add Phar::convertToTar(), Phar::convertToZip(), and Phar::convertToPhar() 2008-01-16 07:24:39 +00:00
Greg Beaver
34bb2d7e76 unixify path separators in tar-based phars, always use this value for duping alias
# found by delete.phpt unit test.  I love unit tests
2008-01-14 06:19:43 +00:00
Greg Beaver
3fd137c88f fix build on windows (Steph Fox) 2008-01-14 02:47:55 +00:00
Greg Beaver
64cb8c8111 fix conflict on win32 if phar compiled statically 2008-01-12 16:18:26 +00:00
Greg Beaver
9bcbbce5bf add definitions for MAX_WBITS in case it isn't defined 2008-01-12 16:15:17 +00:00
Greg Beaver
4df43510b9 make zip optional 2008-01-12 05:17:12 +00:00
Greg Beaver
e9ee7dbfc5 fix compile on windows
remove internal libzip
add required dep on zip (will make optional in a few minutes)
2008-01-12 04:32:19 +00:00
Greg Beaver
8fb4205a8d add Phar::interceptFileFuncs()
To intercept fopen(), file_get_contents(), opendir(), and all the stat-based functions so that
code like "if (is_readable('./config.inc.php'))" actually works inside of a phar
[DOC]
2008-01-11 07:30:03 +00:00
Greg Beaver
7e65f56264 MAPPHAR_ALLOC_FILE slipped in there somehow 2008-01-10 22:05:30 +00:00
Greg Beaver
74df58d255 fix tsrm build, fix various problems with initialization and zlib/bz2-compressed phars 2008-01-10 21:21:38 +00:00
Greg Beaver
ab4c2caf4b add interception of is_dir(), file_exists() and file_get_contents() - will make these optional shortly 2008-01-10 15:13:00 +00:00
Greg Beaver
21ab2ca8e9 fix gzipped phars in phar file format, add test 2008-01-09 08:45:00 +00:00
Greg Beaver
f6b16061d1 implement whole-file compression of phars for phar/tar-based phars
still not 100% working, add failing test
add Phar::isCompressed(), which returns either 0, Phar::GZ, or Phar::BZ2
[DOC]
2008-01-09 07:09:04 +00:00
Greg Beaver
abde85c420 add rmdir() support, add rmdir to dir test
fix *extremely* ancient problem where phar_wrapper_stat always returned success indicating the file existed
rename phar_destroy_manifest to phar_destroy_manifest_entry
2008-01-09 03:47:22 +00:00
Greg Beaver
9f5b3a229f fix empty directories in phar, add test 2008-01-09 00:58:37 +00:00
Greg Beaver
1a3624494e implement mkdir (compiles, not yet tested), support for empty directories in phar (not yet tested)
revert last commit of efree(), it's necessary.
2008-01-08 22:14:16 +00:00
Greg Beaver
4bce48417b split stream file handlers into stream.c and directory handlers into dirstream.c 2008-01-08 20:31:54 +00:00
Greg Beaver
63adb98f78 split out zip functions 2008-01-08 19:40:23 +00:00
Greg Beaver
b93b48663d complete set of new tests for zip-based phars (need to test compression for zip-based phars)
fix a whole bunch of zip-related bugs
tar tests need some naming
add phar information to error messages, fix existing tests to reflect this
2008-01-08 07:08:46 +00:00
Greg Beaver
36efc2a907 eliminate potential double-free of alias
major improvement of zip/tar-based phar stub execution, now __FILE__ says it is the phar, and not phar/.phar/stub.php,
so that the same stub can be used for phar or tar/zip-based phars
ridiculous speedup of rename() within a phar (something like 1000%)
last of the tar-based phar fixes
new tests for tar-based phars, fix existing tests to use new format of __FILE__
2008-01-07 22:21:10 +00:00
Greg Beaver
3dca799fbb fix extension detection for aliases with no extension 2008-01-07 17:18:41 +00:00
Greg Beaver
8a46146f37 fix stat of directory in tar/zip
improve phar recognition of tar/zip-based phars in phar_compile_file
fix segfault in Phar::webPhar() with invalid redirect
add Phar->isTar()/isZip()/isPhar() to determine internal file format
fix creation of tar-based phars from filename in some circumstances
fix read of corrupted file contents from a tar if the tar had been opened readonly and then modified
ensure directories are marked with is_dir in tar file format entries
copy fp_refcount logic into phar_tar_flush() from phar_flush()
fix segfault when flushing a tar with a new stub/alias
2008-01-07 05:41:09 +00:00
Greg Beaver
826e98be83 eliminated memleak, now to make it recognize "dir" as a directory 2008-01-06 05:28:27 +00:00
Greg Beaver
99922cb729 fix typo in phar.c if bz2 is disabled 2008-01-06 05:16:20 +00:00
Greg Beaver
632a633154 fix segfault, add separate tar test for readonly=0 on corrupted tar 2008-01-05 23:02:23 +00:00
Greg Beaver
2fa568b7b0 do not attempt to create a new phar if a file exists and is corrupted or is not a phar archive,
i.e. require a clean slate - a non-existent file or a valid phar archive - to muck around with phar contents
add the first tar-based phar test
2008-01-05 22:46:54 +00:00
Greg Beaver
653dc9e8ce fix front controller tests (requires patch to run-tests.php posted to internals a little while ago)
allow phars to have extension .php as last resort
fix phar-based phars for MIME_OTHER type
2008-01-05 03:41:43 +00:00
Greg Beaver
67688371f7 use zip_free() instead of zip_close(), and don't add a stub if it already exists in phar_zip_flush(), update TODO 2008-01-04 17:04:41 +00:00
Marcus Boerger
95a9f1faf6 - Fix module info for bz2
- Differentiate enabled, disabled and unavailable
2008-01-04 16:10:49 +00:00
Greg Beaver
e8a5b20514 replace crappy $_SERVER munging with explicit munging via
Phar::mungServer().  This static method takes an array with one of these 4 indices (case-sensitive):
'PHP_SELF', 'SCRIPT_NAME', 'SCRIPT_FILENAME', 'REQUEST_URI'
and removes any reference to the actual path on the server.  This allows older apps to function unmodified inside a phar.
the variables are re-registered as PHAR_PHP_SELF and company to allow access from clever script files
[DOC]
2008-01-04 04:57:11 +00:00
Greg Beaver
8e18f1cae1 Phar::webPhar() and various problems relating to shutdown in an apache process fixed 2008-01-04 01:45:37 +00:00
Greg Beaver
f589855093 fix tar-based phars creation and loading 2008-01-03 18:13:27 +00:00
Greg Beaver
8ee4266b3f initial tar support - a few kinks to work on in phar creation, but read works 2008-01-03 04:45:00 +00:00
Greg Beaver
652d39c330 add zip-based phar support. not quite working is webPhar(), not sure why yet 2007-12-31 22:42:40 +00:00
Greg Beaver
e861913e39 fix windows build
# there HAS to be a better way to do this...
2007-12-24 21:40:54 +00:00
Greg Beaver
5200481aaf fix mem leak 2007-12-24 20:30:44 +00:00
Greg Beaver
02c7ff1343 complete re-factoring of front controller. Now it is done with
Phar->webPhar():
<?php
Phar::webPhar();
__HALT_COMPILER();

With the above stub, the default front controller will kick in.  An array of mime type overrides, and another
array mapping phar file entry -> redirected entry can be used to further customize
[DOC]
2007-12-23 21:12:42 +00:00
Greg Beaver
8e4cc4b3dd first attempt at major new feature: default front controller for web
Currently, an entire phar entry is leaked for no obvious reason, otherwise it works.  Sample code:
The phar has to be created using Phar->useFrontController(); and the stub performs actual resolution of which file to load:
<?php
Phar::mapPhar();
include 'phar://' . __FILE__ . '/' . substr($_SERVER['REQUEST_URI'], strlen(basename(__FILE__)));
__HALT_COMPILER();
?>

Phar automatically determines mime type from the file extension and either parses or displays the file.  Modification of REQUEST_URI
and other variables should happen in the stub
[DOC]
2007-12-22 07:46:53 +00:00
Greg Beaver
185a4a8309 on second thought, hooking into getcwd() is a bad idea, who uses this for code loading, anyways? 2007-12-21 04:49:25 +00:00
Greg Beaver
0d830a27ea implement cleaning of crap paths - major functionality boost 2007-12-20 23:12:40 +00:00
Greg Beaver
0bfc046eac remove minor (and unnecessary I might add) windows compile warnings 2007-12-20 04:12:23 +00:00
Greg Beaver
d4eccb4471 holy cow - include/fopen/cwd magic fully working on unix now for windows testing 2007-12-19 04:37:25 +00:00
Greg Beaver
2222da9493 making progress (include magic works) 2007-12-19 03:17:05 +00:00
Greg Beaver
0c51d58138 [unfinished] magically handle getcwd() and fopen() with include_path inside phar
this work is incomplete, but compiles and existing tests pass
2007-12-18 17:01:24 +00:00
Greg Beaver
47cef85c22 fix alias overloading detection on windows 2007-12-14 18:42:57 +00:00
Greg Beaver
4fb3122b16 fix terrible logic discovered in windows testing (not sure how it ever worked on unix) 2007-12-14 18:34:12 +00:00
Greg Beaver
708569029c windows fixes #2 (thanks Steph you rule) 2007-12-14 05:45:48 +00:00
Greg Beaver
c6fe26af37 windows fixes (thanks Steph you rule) 2007-12-14 05:39:20 +00:00
Greg Beaver
38bf150e4d remove stupid*$(# debug code 2007-12-14 05:00:59 +00:00
Greg Beaver
8a614e30db use thread-safe global var to store zend_compile_file, and restore the current zend_compile_file, not the one we
found in MINIT
2007-12-11 19:28:35 +00:00
Greg Beaver
47d859ced2 use stream_copy_to_stream again, figured out how to make the stupid filters work 2007-12-11 19:21:01 +00:00
Greg Beaver
688aef57f8 add the ability to automatically resolve includes inside a phar to files within that phar, so
no code modification is needed to include/require
2007-12-09 21:57:44 +00:00
Greg Beaver
4bcb68a4e8 fix errors found in delMetaData(), add get/delMetaData() to MetaData read test 2007-11-25 05:04:40 +00:00
Greg Beaver
e34be4f8bc preliminary work on using gnupg to verify/create signatures - no implementation, just phpinfo() output and build rules 2007-11-24 04:30:08 +00:00
Greg Beaver
a72251be6e experimental support for optional bz2 extension - should make windows users a whole lot happier 2007-11-24 04:06:44 +00:00
Greg Beaver
b21f49c7c7 MFB fixes for tests 2007-11-22 05:47:28 +00:00
Greg Beaver
43c7e6fa3b fix faulty logic on verification of phar 2007-11-20 05:34:35 +00:00
Greg Beaver
be023d6f62 much better fix for the problem of phar://c:\path\to\blah.phar
don't use php_parse_url() at all, and always unixify paths on copied strings.
our modification was modifying the zval original string, so a user would pass in
phar://c:\path\to\blah.phar

and their string would change to phar://c:/path/to/blah.phar - bad.

Now using

include 'phar://' . __FILE__ . '/index.php';

works on both unix and windows seamlessly, as well as $a = new Phar(__FILE__)

for use in the loader stub
2007-11-19 23:10:05 +00:00
Greg Beaver
4a86b3d6ea Ensure that the same phar can be referenced in multiple logical ways:
1) full path, with \ or / path separator
2) relative path to getcwd()

This should fix the last remaining windows-related quirks as well as similar problems
on unix
2007-11-15 05:21:11 +00:00
Greg Beaver
999961f080 begin win32 fixes for Phar object - still have a problem I can't track down yet, but it's only a matter of time before it is killed too
when passing in a full path with drive letter to the Phar object, we were
then passing "phar://C:/path/to/blah.phar" to php_parse_url(), which
thinks it is getting a valid url scheme "phar", host "C" path "/path/to/blah.phar"

we now pass "phar:///C:/path/to/blah.phar" to make it fail, and then properly
parse the url inside phar
2007-11-13 05:57:14 +00:00
Greg Beaver
6d98d843af fix TSRM, a couple of compile warnings on windows, and test 2007-10-18 19:47:24 +00:00
Greg Beaver
eb67969b73 fix Bug #12124: Phar object cannot be iterated over
remove unused variables
fix jit file open sprintf calls
2007-10-04 03:33:21 +00:00
Greg Beaver
07c509935c fix phar to work with PHP 5.3 2007-10-04 02:24:49 +00:00
Greg Beaver
33347b19f2 when opening an internal file read-only, recycle the phar archive's fp. This makes phar twice as fast (2.21x according to callgrind) 2007-08-30 02:30:16 +00:00
Greg Beaver
5d8919938d fix issue with large number of open file handles killing php with large phars on creation
- close file handles that have no references for entries
- add just-in-time re-processing of file handles
- make sure file size is set in renaming
- add old_flags to phar_entry_info so we can decompress when flushing a modified entry whose fp is closed
2007-08-17 04:47:50 +00:00
Greg Beaver
d3426be1c3 fix several mis-spelled 'temporary's add missing space in comment, and change 'script end' to 'stub end' in manifest read error messages 2007-06-01 03:48:17 +00:00
Marcus Boerger
7ecc0f7fad - Fix memory issue 2007-05-31 06:55:14 +00:00
Marcus Boerger
38bb8cb5af - Fix invalid efree() call 2007-05-28 21:04:42 +00:00
Marcus Boerger
096e123f2d - Verify stub
- Automatically cut off stub after __HALT_COMPILER();
- Always write longest stub ending, so there is no issue with length field
- Add test for setStub from file
- Fix tests
2007-05-27 16:54:37 +00:00
Marcus Boerger
ac05df4759 - For errors "internal corruption of phar ... (truncated manifest)" be more
precise about reason of failure, seperating all error strings
- Fix issue with writing compressed entries
- Fix issue with uncompressing entries
2007-05-27 15:47:52 +00:00
Marcus Boerger
7e1ba8bffb - Fix the fix 2007-05-20 22:14:07 +00:00
Marcus Boerger
73ddcc1fd2 - Fix shutdown 2007-05-20 21:46:54 +00:00
Marcus Boerger
6cbfd2271f - Drop RINIT completely (as discussed @ php|tek) 2007-05-18 04:31:39 +00:00
Marcus Boerger
4313bce995 - Get rid of RINIT completely 2007-05-16 23:20:31 +00:00
Marcus Boerger
5e3af23d20 - Reduce overhead of Phar's RINIT 2007-05-16 23:16:51 +00:00
Marcus Boerger
004932e11d - Add Phar::delMetadata()
- Add Phar::hasMetadata()
- Add Phar::isValidPharFilename()
2007-05-15 20:21:19 +00:00
Marcus Boerger
1ab96f2d04 - Drop commented line 2007-05-14 19:36:44 +00:00
Marcus Boerger
16e27c5aad - Fix main metadata handling, prefix main metadata with main 2007-05-14 19:36:09 +00:00
Marcus Boerger
440691899c - Optimize flushing, don't generate metadata twice 2007-05-14 19:14:00 +00:00
Marcus Boerger
c9c5dbbd8d - Unoptimized fix for metadata writing 2007-05-14 18:59:04 +00:00
Marcus Boerger
7aa7448a32 - Fix Phar::canWrite(), had inverted logic
- Support PHP & builds
2007-05-09 18:09:41 +00:00
Marcus Boerger
ab15beebbf - Compatibility with suhosin 2007-03-27 21:28:22 +00:00
Marcus Boerger
c84b870472 - Prevent rename on extracted archieves 2007-03-26 19:51:22 +00:00
Marcus Boerger
f1684e4735 - Fix return value of unlink/rename handlers
- Add extract_list support to all wrapper handlers but rename
2007-03-26 19:20:00 +00:00
Greg Beaver
e97b1aefbf fix memleak in external dirs
update package.xml
move API to 1.1.0
update package version to 1.1.0RC1
update API test
2007-03-26 16:42:47 +00:00
Greg Beaver
a92eeb61c4 [DOC]
implement setSignatureAlgorithm() and add class constants Phar::MD5, Phar::SHA1, Phar::SHA256, Phar::SHA512, Phar::PGP
2007-03-26 00:00:56 +00:00
Greg Beaver
c3b317f44c default must be SHA1 or we get a BC break 2007-03-25 23:42:49 +00:00
Marcus Boerger
c42a870b7e - Add general SHA-2 support by optional pecl/hash dependency
# We actually need support to select the signature type somehow
2007-03-25 21:43:49 +00:00
Marcus Boerger
b983973a1d - Add ini: phar.extract_list
- Add Phar::getExtractList
- Both allow to set a mapping <phar-file> to <extract-dir>
[[DOC]]
2007-03-25 19:03:38 +00:00
Greg Beaver
e53980587f minor typo s/whetehr/whether/ 2007-03-21 17:14:46 +00:00
Marcus Boerger
94c3896f73 - Provide dedicated hex function for digests 2007-02-24 02:08:08 +00:00
Marcus Boerger
0bd3f367de - Fix issues found with solaris 2007-02-06 23:19:10 +00:00
Marcus Boerger
8f11f4875d - Avoid direct tsrm manipulating in ini setting 2007-02-06 22:41:39 +00:00
Marcus Boerger
bed7c1167d - Fix potential read issues 2007-02-06 22:12:21 +00:00
Antony Dovgal
ea40c23358 fix macros for bigendian platforms 2007-02-06 21:43:46 +00:00
Antony Dovgal
65b47ce346 add missing closing marker 2007-02-06 21:04:22 +00:00
Marcus Boerger
3f3c8fcd10 - Drop another superflous stream close 2007-02-06 20:30:33 +00:00
Marcus Boerger
2a37a1284d - Drop superflous stream close 2007-02-06 20:15:12 +00:00
Greg Beaver
bc17dcfcd1 fix several potential segfaults, add tests for chmod(), fix chmod() 2007-02-06 17:09:37 +00:00
Marcus Boerger
45d63c3973 - Check temp file creation 2007-02-05 22:11:27 +00:00
Greg Beaver
40b66a8035 copyright year updates 2007-02-05 21:38:50 +00:00
Marcus Boerger
357b931e56 - Add additional check & test 2007-02-05 20:47:20 +00:00
Marcus Boerger
250119fa38 - Fix signed/unsigned warnings
- Use safe_emalloc where usefull
2007-02-05 20:34:23 +00:00
Marcus Boerger
c2d5db56ca - Need to drop // 2007-02-04 20:35:59 +00:00
Marcus Boerger
f210205e70 - PHP_VERSION_ID exists only in newer PHPs (5.1+)
- Improve error checking
2007-02-04 20:10:03 +00:00
Marcus Boerger
1c690cb9d4 - Add path sanitizer for new paths
- Add test for a few things we check with the sanitizer
# We might want to use the sanitizer for opening as well
2007-02-04 13:21:40 +00:00
Marcus Boerger
1b5b78ce18 - Provide both version strings, api and ext 2007-02-03 13:20:12 +00:00
Greg Beaver
93b387d327 fix mem leak on error, fix cwd issue. go back to BadMethodCallException for Phar->set*CompressedAllFiles(). ALL TESTS PASS, RELEASE IS IMMINENT 2007-02-03 04:04:18 +00:00
Marcus Boerger
7ae8840c50 - Fix mem access 2007-01-29 07:59:19 +00:00
Greg Beaver
c7a5d062f5 throw exceptions from Phar object, and errors from stream wrapper
# we need to account for uncaught exceptions in shutdown, 2 tests leak because of this
2007-01-29 06:02:19 +00:00
Greg Beaver
c6dc9be489 implement Phar->getMetadata() Phar->setMetadata(), add tests, implement meta-data in the header 2007-01-29 03:59:55 +00:00
Greg Beaver
744ec410ec add rename support 2007-01-28 22:43:38 +00:00
Marcus Boerger
8cfaa44955 - Make new flushing work 2007-01-28 21:26:54 +00:00
Marcus Boerger
d13719ace8 - In Commit reset donotflush 2007-01-28 19:56:09 +00:00
Marcus Boerger
ea9796cca4 - Drop phar_destroy_phar_data() from api 2007-01-28 12:18:07 +00:00
Marcus Boerger
e1db72467c - Fix read/write mode handling 2007-01-28 10:32:45 +00:00
Greg Beaver
e8cabb46f6 fix commitWrite test, enable creation of Phars with phar object 2007-01-28 05:40:18 +00:00
Greg Beaver
2513903e40 stream context for specifying meta-data 2007-01-28 03:25:53 +00:00
Marcus Boerger
4b2eed1fc1 - Clean up on flush 2007-01-27 23:02:42 +00:00
Marcus Boerger
f86b7b96fc - Refcounting 2007-01-27 22:23:52 +00:00
Marcus Boerger
426146b340 - More on 5.2.1 support 2007-01-27 22:18:18 +00:00
Marcus Boerger
ec6c58ca94 - Add 5.2.1 support 2007-01-27 21:34:40 +00:00
Marcus Boerger
fc8754c892 - Dropped one line by accident 2007-01-27 21:24:28 +00:00
Marcus Boerger
d5bbd84d76 - Prevent memory corruption 2007-01-27 21:23:02 +00:00
Marcus Boerger
c7523db97f - Cannot change stream here 2007-01-27 19:42:37 +00:00
Greg Beaver
7b6b53b83d php_stream_truncate_set_size() is a noop with temp streams.
so, we're going to use a brand new tempfile for truncation.

ALL TESTS PASS NOW (finally)
2007-01-27 18:57:12 +00:00
Greg Beaver
1d11c2c4a7 fix memleaks and all but 1 test 2007-01-27 18:45:48 +00:00
Greg Beaver
78f1b9401b fix memleak in unlink() 2007-01-27 18:27:19 +00:00
Greg Beaver
74d7701b2b fix incorrect refcount increment on unlink() 2007-01-27 18:03:40 +00:00
Marcus Boerger
13e860e66f - Fix memory access 2007-01-27 17:27:48 +00:00
Marcus Boerger
ced8e1d9d1 - Make phar_flush() work without reloading
- Make refcounting fly
2007-01-27 15:31:24 +00:00
Marcus Boerger
9cd8d73677 - Simplify by providing delref function 2007-01-26 19:58:22 +00:00
Marcus Boerger
e52a5adc34 - Fix stream closing 2007-01-26 19:43:04 +00:00
Greg Beaver
8de7bd61bf implement phar refcounting
move setStub to commitWrite() and add beginWrite()

# many oo-based tests still fail, they need to be tweaked and fixed
2007-01-26 14:52:10 +00:00
Antony Dovgal
d6af95d1a4 fix folding and a couple of typos 2007-01-23 23:31:14 +00:00
Greg Beaver
d8c26fd461 fix tests, fix corruption issues with compression, simplify code. 3 tests still fail, memory leaks and mysterious crc error - the 16 tests are faulty 2007-01-22 03:41:41 +00:00
Marcus Boerger
03dfef9f99 -Simplify 2007-01-22 02:07:45 +00:00
Marcus Boerger
261749d402 - Generate CRC32 in case not done in original file 2007-01-22 02:04:51 +00:00
Marcus Boerger
79985976a6 - CRC is done on uncompressed data 2007-01-22 02:00:18 +00:00
Marcus Boerger
2312d0772d - Drop erroneously added numbers in error messages 2007-01-22 01:01:50 +00:00
Marcus Boerger
ed454d0fc8 - Finish get/setStub() 2007-01-22 00:59:02 +00:00
Greg Beaver
27f4a3ad30 add setUncompressed(), setCompressedGZ(), setCompressedBZ2() to PharFileInfo, and a failing test (due to bug in streams + bug in phar) 2007-01-22 00:13:20 +00:00
Greg Beaver
9c2651d210 X Phar->setStub() for specifying a new stub to the phar [Greg] 2007-01-21 23:22:57 +00:00
Marcus Boerger
d0d87d8435 - Rewrite/Finish metadata handling 2007-01-21 20:12:50 +00:00
Marcus Boerger
a02afe32c1 - Fix issues with metadata testing 2007-01-21 15:57:12 +00:00
Marcus Boerger
c440902e04 - Simplify dtor
- Zero terminate meta data
2007-01-21 15:28:56 +00:00
Marcus Boerger
3066cfb3ef - Disable most of class Phar and all of class PharFileInfo if SPL is not present 2007-01-21 15:25:50 +00:00
Greg Beaver
f21a0cdd0c fix final memory leak, fix metadata reading (simple), add basic test that it doesn't break 2007-01-21 06:54:04 +00:00
Greg Beaver
d661faefda fix 1 mem leak 2007-01-21 06:39:32 +00:00
Greg Beaver
5bbd10296c implement reading meta-data from phars. writing is not yet supported 2007-01-21 06:30:55 +00:00
Greg Beaver
773fc51457 implement ini handler for phar.readonly and phar.require_hash that allows enabling it on
PHP_INI_ALL if it is disabled in the system, but does not allow disabling it
   if it is enabled in the syste
2007-01-20 22:40:47 +00:00
Marcus Boerger
154de1819e - Fix flags and tests 2007-01-20 16:43:45 +00:00
Greg Beaver
a5dff13465 update TODO to include missing items
move permissions to the lowest bits of flags
fix warnings about signedness
fix unclear /* docs */
2007-01-20 05:28:48 +00:00
Greg Beaver
c35b9f30b6 add class constants Phar::COMPRESSED, Phar::GZ, and Phar::BZ2 for eventual compression manipulation 2007-01-18 00:13:18 +00:00
Greg Beaver
28d4b75d26 fix for deleted files when read from, generalize refcount1 test better 2007-01-16 03:41:52 +00:00
Greg Beaver
05f0989797 tweak docs for canCompress 2007-01-16 00:00:26 +00:00