mirror of
https://github.com/php/php-src.git
synced 2024-09-24 03:17:26 +00:00
add externally parsed files to temporary manifest (this will be made
optional and must be explicitly enabled per-phar)
This commit is contained in:
parent
9dd2afc1d4
commit
9c62ef1124
@ -2567,12 +2567,19 @@ int phar_zend_open(const char *filename, zend_file_handle *handle TSRMLS_DC) /*
|
||||
if (SUCCESS == (zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar))) {
|
||||
if (!(entry = phar_find_in_include_path(entry, old, *pphar TSRMLS_CC))) {
|
||||
/* this file is not in the phar, use the original path */
|
||||
if (SUCCESS == phar_orig_zend_open(filename, handle TSRMLS_CC)) {
|
||||
if (filename[0] != '.' && SUCCESS == phar_mount_entry(*pphar, handle->opened_path ? handle->opened_path : filename, strlen(handle->opened_path ? handle->opened_path : filename), filename, strlen(filename), 0)) {
|
||||
entry = (char *) filename;
|
||||
goto dopharthing;
|
||||
}
|
||||
}
|
||||
efree(old);
|
||||
efree(arch);
|
||||
goto skip_phar;
|
||||
}
|
||||
}
|
||||
}
|
||||
dopharthing:
|
||||
efree(old);
|
||||
/* auto-convert to phar:// */
|
||||
spprintf(&name, 4096, "phar://%s/%s", arch, entry);
|
||||
|
34
ext/phar/tests/tempmanifest1.phpt
Normal file
34
ext/phar/tests/tempmanifest1.phpt
Normal file
@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
Phar: temporary manifest entry test
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
--INI--
|
||||
phar.readonly=0
|
||||
--FILE--
|
||||
<?php
|
||||
$fname = dirname(__FILE__) . '/tempmanifest1.phar.php';
|
||||
$a = new Phar($fname);
|
||||
$a['index.php'] = '<?php
|
||||
set_include_path("' . addslashes(dirname(__FILE__)) . '");
|
||||
include "extfile.php";
|
||||
?>';
|
||||
$a->setStub('<?php
|
||||
include "phar://" . __FILE__ . "/index.php";
|
||||
__HALT_COMPILER();');
|
||||
unset($a);
|
||||
file_put_contents(dirname(__FILE__) . '/extfile.php', '<?php
|
||||
var_dump(__FILE__);
|
||||
?>');
|
||||
include dirname(__FILE__) . '/extfile.php';
|
||||
include $fname;
|
||||
?>
|
||||
===DONE===
|
||||
--CLEAN--
|
||||
<?php
|
||||
@unlink(dirname(__FILE__) . '/tempmanifest1.phar.php');
|
||||
@unlink(dirname(__FILE__) . '/extfile.php');
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(%d) "%sextfile.php"
|
||||
string(%d) "phar://%sextfile.php"
|
||||
===DONE===
|
@ -78,6 +78,7 @@ int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t positi
|
||||
int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, char *path, int path_len, int is_dir TSRMLS_DC)
|
||||
{
|
||||
phar_entry_info entry = {0};
|
||||
php_stream_statbuf ssb;
|
||||
|
||||
#if PHP_MAJOR_VERSION < 6
|
||||
if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
|
||||
@ -98,7 +99,20 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len,
|
||||
entry.is_crc_checked = 1;
|
||||
entry.fp_type = PHAR_TMP;
|
||||
entry.is_dir = is_dir;
|
||||
return zend_hash_add(&phar->manifest, path, path_len, (void*)&entry, sizeof(phar_entry_info), NULL);
|
||||
|
||||
if (SUCCESS != php_stream_stat_path(entry.link, &ssb)) {
|
||||
efree(entry.link);
|
||||
efree(entry.filename);
|
||||
return FAILURE;
|
||||
}
|
||||
entry.uncompressed_filesize = entry.compressed_filesize = ssb.sb.st_size;
|
||||
entry.flags = ssb.sb.st_mode;
|
||||
if (SUCCESS == zend_hash_add(&phar->manifest, path, path_len, (void*)&entry, sizeof(phar_entry_info), NULL)) {
|
||||
return SUCCESS;
|
||||
}
|
||||
efree(entry.link);
|
||||
efree(entry.filename);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
char *phar_find_in_include_path(char *file, char *entry, phar_archive_data *phar TSRMLS_DC) /* {{{ */
|
||||
@ -416,6 +430,12 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error TSRMLS_DC)
|
||||
char *filtername;
|
||||
off_t loc;
|
||||
|
||||
if (entry->fp_type == PHAR_TMP) {
|
||||
if (!entry->fp) {
|
||||
entry->fp = php_stream_open_wrapper(entry->link, "rb", STREAM_MUST_SEEK|0, NULL);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
if (entry->fp_type != PHAR_FP) {
|
||||
/* either newly created or already modified */
|
||||
return SUCCESS;
|
||||
|
Loading…
Reference in New Issue
Block a user