Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ PHP 8.6 UPGRADE NOTES
with empty data (e.g. to destroy the session) should implement the same
logic in their updateTimestamp() method.

- SPL:
. SplFileObject::next() now advances the stream when no prior current()
call has cached a line. A subsequent current() call returns the new
line rather than the previous one.
. SplFileObject::fgets() no longer caches the returned line for
subsequent current() calls. current() now re-reads from the current
stream position instead of returning the line fgets() just returned.
. SplFileObject::next() past EOF no longer increments key() without
bound. SplFileObject::seek() past EOF now produces the same key()
value as SplTempFileObject; the two previously returned different
values.

- Standard:
. Form feed (\f) is now added in the default trimmed characters of trim(),
rtrim() and ltrim(). RFC: https://wiki.php.net/rfc/trim_form_feed
Expand Down
82 changes: 39 additions & 43 deletions ext/phar/func_interceptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ PHP_FUNCTION(phar_opendir) /* {{{ */
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
entry_len = filename_len;
/* retrieving a file within the current directory, so use this if possible */
entry = phar_fix_filepath(entry, &entry_len, 1);
entry = phar_fix_filepath(entry, &entry_len, true);

if (entry[0] == '/') {
spprintf(&name, 4096, "phar://%s%s", arch, entry);
Expand Down Expand Up @@ -117,19 +117,18 @@ static zend_string* phar_get_name_for_relative_paths(zend_string *filename, bool
}
} else {
size_t entry_len = ZSTR_LEN(filename);
char *entry = phar_fix_filepath(estrndup(ZSTR_VAL(filename), ZSTR_LEN(filename)), &entry_len, 1);
char *entry = phar_fix_filepath(estrndup(ZSTR_VAL(filename), ZSTR_LEN(filename)), &entry_len, true);
bool is_in_phar;
if (entry[0] == '/') {
if (!zend_hash_str_exists(&(phar->manifest), entry + 1, entry_len - 1)) {
/* this file is not in the phar, use the original path */
notfound:
efree(entry);
efree(arch);
return NULL;
}
is_in_phar = zend_hash_str_exists(&(phar->manifest), entry + 1, entry_len - 1);
} else {
if (!zend_hash_str_exists(&(phar->manifest), entry, entry_len)) {
goto notfound;
}
is_in_phar = zend_hash_str_exists(&(phar->manifest), entry, entry_len);
}
/* this file is not in the phar, use the original path */
if (!is_in_phar) {
efree(entry);
efree(arch);
return NULL;
}
/* auto-convert to phar:// */
if (entry[0] == '/') {
Expand Down Expand Up @@ -483,7 +482,6 @@ static void phar_file_stat(const char *filename, size_t filename_length, int typ
size_t arch_len, entry_len;
zend_string *fname;
zend_stat_t sb = {0};
phar_entry_info *data = NULL;
phar_archive_data *phar;

fname = zend_get_executed_filename_ex();
Expand Down Expand Up @@ -513,15 +511,18 @@ static void phar_file_stat(const char *filename, size_t filename_length, int typ
goto skip_phar;
}
splitted:
entry = phar_fix_filepath(entry, &entry_len, 1);
entry = phar_fix_filepath(entry, &entry_len, true);
const phar_entry_info *data = NULL;
if (entry[0] == '/') {
if (NULL != (data = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1))) {
data = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1);
if (data) {
efree(entry);
goto stat_entry;
}
goto notfound;
}
if (NULL != (data = zend_hash_str_find_ptr(&(phar->manifest), entry, entry_len))) {
data = zend_hash_str_find_ptr(&(phar->manifest), entry, entry_len);
if (data) {
efree(entry);
goto stat_entry;
}
Expand Down Expand Up @@ -552,8 +553,9 @@ static void phar_file_stat(const char *filename, size_t filename_length, int typ
PHAR_G(cwd) = "/";
PHAR_G(cwd_len) = 0;
/* clean path without cwd */
entry = phar_fix_filepath(entry, &entry_len, 1);
if (NULL != (data = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1))) {
entry = phar_fix_filepath(entry, &entry_len, true);
data = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1);
if (data) {
PHAR_G(cwd) = save;
PHAR_G(cwd_len) = save_len;
efree(entry);
Expand Down Expand Up @@ -755,20 +757,18 @@ PHP_FUNCTION(phar_is_file) /* {{{ */
if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
phar_entry_info *etemp;

entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1);
entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, true);
if (entry[0] == '/') {
if (NULL != (etemp = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1))) {
/* this file is not in the current directory, use the original path */
found_it:
efree(entry);
efree(arch);
RETURN_BOOL(!etemp->is_dir);
}
etemp = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1);
} else {
if (NULL != (etemp = zend_hash_str_find_ptr(&(phar->manifest), entry, entry_len))) {
goto found_it;
}
etemp = zend_hash_str_find_ptr(&(phar->manifest), entry, entry_len);
}
if (etemp) {
efree(entry);
efree(arch);
RETURN_BOOL(!etemp->is_dir);
}
/* this file is not in the current directory, use the original path */
}
if (entry != filename) {
efree(entry);
Expand Down Expand Up @@ -800,7 +800,7 @@ PHP_FUNCTION(phar_is_link) /* {{{ */
goto skip_phar;
}
if (!IS_ABSOLUTE_PATH(filename, filename_len) && !strstr(filename, "://")) {
char *arch, *entry;
char *arch;
size_t arch_len, entry_len;
zend_string *fname = zend_get_executed_filename_ex();

Expand All @@ -813,29 +813,25 @@ PHP_FUNCTION(phar_is_link) /* {{{ */
if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0)) {
phar_archive_data *phar;

entry = filename;
char *entry = filename;
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
entry_len = filename_len;
/* retrieving a file within the current directory, so use this if possible */
if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
phar_entry_info *etemp;

entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, 1);
entry = phar_fix_filepath(estrndup(entry, entry_len), &entry_len, true);
if (entry[0] == '/') {
if (NULL != (etemp = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1))) {
/* this file is not in the current directory, use the original path */
found_it:
efree(entry);
efree(arch);
RETURN_BOOL(etemp->link);
}
etemp = zend_hash_str_find_ptr(&(phar->manifest), entry + 1, entry_len - 1);
} else {
if (NULL != (etemp = zend_hash_str_find_ptr(&(phar->manifest), entry, entry_len))) {
goto found_it;
}
etemp = zend_hash_str_find_ptr(&(phar->manifest), entry, entry_len);
}
efree(entry);
if (etemp) {
efree(arch);
RETURN_BOOL(etemp->link);
}
}
efree(entry);
efree(arch);
RETURN_FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion ext/phar/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ zend_string *phar_find_in_include_path(zend_string *filename, phar_archive_data
}

try_len = ZSTR_LEN(filename);
test = phar_fix_filepath(estrndup(ZSTR_VAL(filename), ZSTR_LEN(filename)), &try_len, 1);
test = phar_fix_filepath(estrndup(ZSTR_VAL(filename), ZSTR_LEN(filename)), &try_len, true);

if (*test == '/') {
if (zend_hash_str_exists(&(phar->manifest), test + 1, try_len - 1)) {
Expand Down