diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index 1e41b2d0801d..672cebe7bed7 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -250,8 +250,8 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, if (!resource->scheme || !resource->host || !resource->path) { if (resource->host && !resource->path) { php_stream_wrapper_log_warn(wrapper, context, options, InvalidPath, - "phar error: no directory in \"%s\", must have at least phar://%s/ for root directory (always use full path to a new phar)", - path, ZSTR_VAL(resource->host)); + "phar error: no directory in \"%s\", must have at least phar://%pS/ for root directory (always use full path to a new phar)", + path, resource->host); php_url_free(resource); return NULL; } @@ -277,7 +277,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path, efree(error); } else { php_stream_wrapper_log_warn(wrapper, context, options, NotFound, - "phar file \"%s\" is unknown", ZSTR_VAL(resource->host)); + "phar file \"%pS\" is unknown", resource->host); } php_url_free(resource); return NULL; @@ -379,8 +379,8 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo phar = phar_get_archive(ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), NULL, 0, &error); if (!phar) { php_stream_wrapper_log_warn(wrapper, context, options, MkdirFailed, - "phar error: cannot create directory \"%s\" in phar \"%s\", error retrieving phar information: %s", - ZSTR_VAL(resource->path) + 1, ZSTR_VAL(resource->host), error); + "phar error: cannot create directory \"%s\" in phar \"%pS\", error retrieving phar information: %s", + ZSTR_VAL(resource->path) + 1, resource->host, error); efree(error); php_url_free(resource); return 0; @@ -394,16 +394,16 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo efree(e); } php_stream_wrapper_log_warn(wrapper, context, options, AlreadyExists, - "phar error: cannot create directory \"%s\" in phar \"%s\", directory already exists", - ZSTR_VAL(resource->path)+1, ZSTR_VAL(resource->host)); + "phar error: cannot create directory \"%s\" in phar \"%pS\", directory already exists", + ZSTR_VAL(resource->path)+1, resource->host); php_url_free(resource); return 0; } if (error) { php_stream_wrapper_log_warn(wrapper, context, options, MkdirFailed, - "phar error: cannot create directory \"%s\" in phar \"%s\", %s", - ZSTR_VAL(resource->path)+1, ZSTR_VAL(resource->host), error); + "phar error: cannot create directory \"%s\" in phar \"%pS\", %s", + ZSTR_VAL(resource->path)+1, resource->host, error); efree(error); php_url_free(resource); return 0; @@ -412,16 +412,16 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo if (phar_get_entry_info_dir(phar, ZSTR_VAL(resource->path) + 1, ZSTR_LEN(resource->path) - 1, 0, &error, true)) { /* entry exists as a file */ php_stream_wrapper_log_warn(wrapper, context, options, AlreadyExists, - "phar error: cannot create directory \"%s\" in phar \"%s\", file already exists", - ZSTR_VAL(resource->path)+1, ZSTR_VAL(resource->host)); + "phar error: cannot create directory \"%s\" in phar \"%pS\", file already exists", + ZSTR_VAL(resource->path)+1, resource->host); php_url_free(resource); return 0; } if (error) { php_stream_wrapper_log_warn(wrapper, context, options, MkdirFailed, - "phar error: cannot create directory \"%s\" in phar \"%s\", %s", - ZSTR_VAL(resource->path)+1, ZSTR_VAL(resource->host), error); + "phar error: cannot create directory \"%s\" in phar \"%pS\", %s", + ZSTR_VAL(resource->path)+1, resource->host, error); efree(error); php_url_free(resource); return 0; @@ -451,8 +451,8 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo if (NULL == zend_hash_add_mem(&phar->manifest, entry.filename, &entry, sizeof(phar_entry_info))) { php_stream_wrapper_log_warn(wrapper, context, options, MkdirFailed, - "phar error: cannot create directory \"%s\" in phar \"%s\", adding to manifest failed", - ZSTR_VAL(entry.filename), ZSTR_VAL(phar->fname)); + "phar error: cannot create directory \"%pS\" in phar \"%pS\", adding to manifest failed", + entry.filename, phar->fname); zend_string_efree(entry.filename); return 0; } @@ -461,8 +461,8 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo if (error) { php_stream_wrapper_log_warn(wrapper, context, options, MkdirFailed, - "phar error: cannot create directory \"%s\" in phar \"%s\", %s", - ZSTR_VAL(entry.filename), ZSTR_VAL(phar->fname), error); + "phar error: cannot create directory \"%pS\" in phar \"%pS\", %s", + entry.filename, phar->fname, error); zend_hash_del(&phar->manifest, entry.filename); efree(error); return 0; @@ -521,8 +521,8 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options phar = phar_get_archive(ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), NULL, 0, &error); if (!phar) { php_stream_wrapper_log_warn(wrapper, context, options, RmdirFailed, - "phar error: cannot remove directory \"%s\" in phar \"%s\", error retrieving phar information: %s", - ZSTR_VAL(resource->path)+1, ZSTR_VAL(resource->host), error); + "phar error: cannot remove directory \"%s\" in phar \"%pS\", error retrieving phar information: %s", + ZSTR_VAL(resource->path)+1, resource->host, error); efree(error); php_url_free(resource); return 0; @@ -534,13 +534,13 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options if (!entry) { if (error) { php_stream_wrapper_log_warn(wrapper, context, options, RmdirFailed, - "phar error: cannot remove directory \"%s\" in phar \"%s\", %s", - ZSTR_VAL(resource->path)+1, ZSTR_VAL(resource->host), error); + "phar error: cannot remove directory \"%s\" in phar \"%pS\", %s", + ZSTR_VAL(resource->path)+1, resource->host, error); efree(error); } else { php_stream_wrapper_log_warn(wrapper, context, options, NotFound, - "phar error: cannot remove directory \"%s\" in phar \"%s\", directory does not exist", - ZSTR_VAL(resource->path)+1, ZSTR_VAL(resource->host)); + "phar error: cannot remove directory \"%s\" in phar \"%pS\", directory does not exist", + ZSTR_VAL(resource->path)+1, resource->host); } php_url_free(resource); return 0; @@ -594,8 +594,8 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options if (error) { php_stream_wrapper_log_warn(wrapper, context, options, RmdirFailed, - "phar error: cannot remove directory \"%s\" in phar \"%s\", %s", - ZSTR_VAL(entry->filename), ZSTR_VAL(phar->fname), error); + "phar error: cannot remove directory \"%pS\" in phar \"%pS\", %s", + entry->filename, phar->fname, error); php_url_free(resource); efree(error); return 0; diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index f6e69f20035c..e4cf1933b797 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -57,9 +57,9 @@ PHP_FUNCTION(phar_opendir) /* {{{ */ zend_string *entry = phar_fix_filepath(filename, filename_len, true); if (ZSTR_VAL(entry)[0] == '/') { - spprintf(&name, 4096, "phar://%s%s", ZSTR_VAL(arch), ZSTR_VAL(entry)); + spprintf(&name, 4096, "phar://%pS%pS", arch, entry); } else { - spprintf(&name, 4096, "phar://%s/%s", ZSTR_VAL(arch), ZSTR_VAL(entry)); + spprintf(&name, 4096, "phar://%pS/%pS", arch, entry); } zend_string_release_ex(entry, false); zend_string_release_ex(arch, false); @@ -135,7 +135,7 @@ static zend_string* phar_get_name_for_relative_paths(zend_string *filename, bool ZSTR_VAL(entry), ZSTR_LEN(entry) ); } else { - name = strpprintf(4096, "phar://%s/%s", ZSTR_VAL(arch), ZSTR_VAL(entry)); + name = strpprintf(4096, "phar://%pS/%pS", arch, entry); } zend_string_release_ex(entry, false); } diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 9f0ccc627279..a20ede487d3e 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -3192,7 +3192,7 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type) zend_file_handle f; /* zip or tar-based phar */ - name = zend_strpprintf(4096, "phar://%s/%s", ZSTR_VAL(file_handle->filename), ".phar/stub.php"); + name = zend_strpprintf(4096, "phar://%pS/%s", file_handle->filename, ".phar/stub.php"); zend_stream_init_filename_ex(&f, name); if (SUCCESS == zend_stream_open_function(&f)) { zend_string_release(f.filename); diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 8a330a954b89..e0f3b4e3ed2e 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -493,14 +493,14 @@ PHP_METHOD(Phar, mount) } } - zend_throw_exception_ex(phar_ce_PharException, 0, "%s is not a phar archive, cannot mount", ZSTR_VAL(arch)); + zend_throw_exception_ex(phar_ce_PharException, 0, "%pS is not a phar archive, cannot mount", arch); zend_string_release_ex(arch, false); goto finish; } carry_on: if (SUCCESS != phar_mount_entry(pphar, actual, actual_len, path, path_len)) { - zend_throw_exception_ex(phar_ce_PharException, 0, "Mounting of %s to %s within phar %s failed", path, actual, ZSTR_VAL(arch)); + zend_throw_exception_ex(phar_ce_PharException, 0, "Mounting of %s to %s within phar %pS failed", path, actual, arch); } if (entry && path == ZSTR_VAL(entry)) { @@ -1268,10 +1268,10 @@ PHP_METHOD(Phar, unlinkArchive) if (FAILURE == phar_open_from_filename(ZSTR_VAL(fname), ZSTR_LEN(fname), NULL, REPORT_ERRORS, &phar, &error)) { if (error) { - zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown phar archive \"%s\": %s", ZSTR_VAL(fname), error); + zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown phar archive \"%pS\": %s", fname, error); efree(error); } else { - zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown phar archive \"%s\"", ZSTR_VAL(fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown phar archive \"%pS\"", fname); } RETURN_THROWS(); } @@ -1282,7 +1282,7 @@ PHP_METHOD(Phar, unlinkArchive) if (arch) { if (zend_string_equals(arch, fname)) { zend_string_release_ex(arch, false); - zend_throw_exception_ex(phar_ce_PharException, 0, "phar archive \"%s\" cannot be unlinked from within itself", ZSTR_VAL(fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar archive \"%pS\" cannot be unlinked from within itself", fname); RETURN_THROWS(); } zend_string_release_ex(arch, false); @@ -1290,12 +1290,12 @@ PHP_METHOD(Phar, unlinkArchive) } if (phar->is_persistent) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar archive \"%s\" is in phar.cache_list, cannot unlinkArchive()", ZSTR_VAL(fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar archive \"%pS\" is in phar.cache_list, cannot unlinkArchive()", fname); RETURN_THROWS(); } if (phar->refcount) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar archive \"%s\" has open file handles or objects. fclose() all file handles, and unset() all objects prior to calling unlinkArchive()", ZSTR_VAL(fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar archive \"%pS\" has open file handles or objects. fclose() all file handles, and unset() all objects prior to calling unlinkArchive()", fname); RETURN_THROWS(); } @@ -1399,7 +1399,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ if (!value) { /* failure in get_current_data */ - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned no value", ZSTR_VAL(ce->name)); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %pS returned no value", ce->name); return ZEND_HASH_APPLY_STOP; } @@ -1410,7 +1410,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ php_stream_from_zval_no_verify(fp, value); if (!fp) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %s returned an invalid stream handle", ZSTR_VAL(ce->name)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %pS returned an invalid stream handle", ce->name); return ZEND_HASH_APPLY_STOP; } @@ -1424,7 +1424,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ if (Z_TYPE(key) != IS_STRING) { zval_ptr_dtor(&key); - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %pS returned an invalid key (must return a string)", ce->name); return ZEND_HASH_APPLY_STOP; } @@ -1434,7 +1434,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ save = str_key; zval_ptr_dtor_str(&key); } else { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %pS returned an invalid key (must return a string)", ce->name); return ZEND_HASH_APPLY_STOP; } @@ -1446,7 +1446,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ spl_filesystem_object *intern = PHAR_FETCH_INTERNAL_EX(value); if (!base_len) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %s returns an SplFileInfo object, so base directory must be specified", ZSTR_VAL(ce->name)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %pS returns an SplFileInfo object, so base directory must be specified", ce->name); return ZEND_HASH_APPLY_STOP; } @@ -1506,7 +1506,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ } ZEND_FALLTHROUGH; default: - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid value (must return a string, a stream, or an SplFileInfo object)", ZSTR_VAL(ce->name)); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %pS returned an invalid value (must return a string, a stream, or an SplFileInfo object)", ce->name); return ZEND_HASH_APPLY_STOP; } @@ -1546,7 +1546,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ } } else { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned a path \"%s\" that is not in the base directory \"%s\"", ZSTR_VAL(ce->name), fname, base); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %pS returned a path \"%s\" that is not in the base directory \"%s\"", ce->name, fname, base); if (save) { efree(save); @@ -1566,7 +1566,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ if (Z_TYPE(key) != IS_STRING) { zval_ptr_dtor(&key); - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %pS returned an invalid key (must return a string)", ce->name); return ZEND_HASH_APPLY_STOP; } @@ -1576,13 +1576,13 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ save = str_key; zval_ptr_dtor_str(&key); } else { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid key (must return a string)", ZSTR_VAL(ce->name)); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %pS returned an invalid key (must return a string)", ce->name); return ZEND_HASH_APPLY_STOP; } } if (php_check_open_basedir(fname)) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned a path \"%s\" that open_basedir prevents opening", ZSTR_VAL(ce->name), fname); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %pS returned a path \"%s\" that open_basedir prevents opening", ce->name, fname); if (save) { efree(save); @@ -1599,7 +1599,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ fp = php_stream_open_wrapper(fname, "rb", STREAM_MUST_SEEK|0, &opened); if (!fp) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned a file that could not be opened \"%s\"", ZSTR_VAL(ce->name), fname); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %pS returned a file that could not be opened \"%s\"", ce->name, fname); if (save) { efree(save); @@ -1765,7 +1765,7 @@ PHP_METHOD(Phar, buildFromDirectory) if (apply_reg) { zval_ptr_dtor(®exiter); } - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" unable to create temporary file", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" unable to create temporary file", phar_obj->archive->fname); RETURN_THROWS(); } @@ -1775,7 +1775,7 @@ PHP_METHOD(Phar, buildFromDirectory) zval_ptr_dtor(®exiter); } php_stream_close(pass.fp); - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } @@ -1833,7 +1833,7 @@ PHP_METHOD(Phar, buildFromIterator) } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } @@ -1846,7 +1846,7 @@ PHP_METHOD(Phar, buildFromIterator) pass.count = 0; pass.fp = php_stream_fopen_tmpfile(); if (pass.fp == NULL) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\": unable to create temporary file", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\": unable to create temporary file", phar_obj->archive->fname); RETURN_THROWS(); } @@ -1915,11 +1915,11 @@ static zend_result phar_copy_file_contents(phar_entry_info *entry, php_stream *f if (FAILURE == phar_open_entry_fp(entry, &error, true)) { if (error) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "Cannot convert phar archive \"%s\", unable to open entry \"%s\" contents: %s", ZSTR_VAL(entry->phar->fname), ZSTR_VAL(entry->filename), error); + "Cannot convert phar archive \"%pS\", unable to open entry \"%pS\" contents: %s", entry->phar->fname, entry->filename, error); efree(error); } else { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "Cannot convert phar archive \"%s\", unable to open entry \"%s\" contents", ZSTR_VAL(entry->phar->fname), ZSTR_VAL(entry->filename)); + "Cannot convert phar archive \"%pS\", unable to open entry \"%pS\" contents", entry->phar->fname, entry->filename); } return FAILURE; } @@ -1929,7 +1929,7 @@ static zend_result phar_copy_file_contents(phar_entry_info *entry, php_stream *f offset = php_stream_tell(fp); if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, false), fp, entry->uncompressed_filesize, NULL)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "Cannot convert phar archive \"%s\", unable to copy entry \"%s\" contents", ZSTR_VAL(entry->phar->fname), ZSTR_VAL(entry->filename)); + "Cannot convert phar archive \"%pS\", unable to copy entry \"%pS\" contents", entry->phar->fname, entry->filename); return FAILURE; } @@ -2022,9 +2022,9 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* } else if (phar_path_check(&ext, &ext_len, &pcr_error) > pcr_is_ok) { if (phar->is_data) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar converted from \"%s\" has invalid extension %s", ZSTR_VAL(phar->fname), ext); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar converted from \"%pS\" has invalid extension %s", phar->fname, ext); } else { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar converted from \"%s\" has invalid extension %s", ZSTR_VAL(phar->fname), ext); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar converted from \"%pS\" has invalid extension %s", phar->fname, ext); } return NULL; } @@ -2086,7 +2086,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* efree(newname); if (PHAR_G(manifest_cached) && NULL != (pphar = zend_hash_find_ptr(&cached_phars, newpath))) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars, new phar name is in phar.cache_list", ZSTR_VAL(phar->fname)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%pS\" to the list of phars, new phar name is in phar.cache_list", phar->fname); goto err_oldpath; } @@ -2111,17 +2111,17 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* } } - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars, a phar with that name already exists", ZSTR_VAL(phar->fname)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%pS\" to the list of phars, a phar with that name already exists", phar->fname); goto err_oldpath; } its_ok: if (SUCCESS == php_stream_stat_path(ZSTR_VAL(newpath), &ssb)) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" exists and must be unlinked prior to conversion", ZSTR_VAL(newpath)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%pS\" exists and must be unlinked prior to conversion", newpath); goto err_reused_oldpath; } if (!phar->is_data) { if (SUCCESS != phar_detect_phar_fname_ext(ZSTR_VAL(newpath), ZSTR_LEN(newpath), &(phar->ext), &ext_len, 1, 1, true)) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" has invalid extension %s", ZSTR_VAL(phar->fname), ext); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%pS\" has invalid extension %s", phar->fname, ext); goto err_reused_oldpath; } phar->ext_len = ext_len; @@ -2144,7 +2144,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* } else { if (SUCCESS != phar_detect_phar_fname_ext(ZSTR_VAL(newpath), ZSTR_LEN(newpath), &(phar->ext), &ext_len, 0, 1, true)) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar \"%s\" has invalid extension %s", ZSTR_VAL(phar->fname), ext); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar \"%pS\" has invalid extension %s", phar->fname, ext); goto err_reused_oldpath; } phar->ext_len = ext_len; @@ -2157,7 +2157,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* } if ((!pphar || phar == pphar) && NULL == zend_hash_update_ptr(&(PHAR_G(phar_fname_map)), newpath, phar)) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%s\" to the list of phars", ZSTR_VAL(phar->fname)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to add newly converted phar \"%pS\" to the list of phars", phar->fname); goto err_oldpath; } @@ -2601,7 +2601,7 @@ PHP_METHOD(Phar, delete) } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } if (NULL != (entry = zend_hash_find_ptr(&phar_obj->archive->manifest, file_name))) { @@ -2614,7 +2614,7 @@ PHP_METHOD(Phar, delete) phar_obj->archive->is_modified = 1; } } else { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist and cannot be deleted", ZSTR_VAL(file_name)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %pS does not exist and cannot be deleted", file_name); RETURN_THROWS(); } @@ -2697,16 +2697,16 @@ PHP_METHOD(Phar, setAlias) } if (NULL != (fd_ptr = zend_hash_find_ptr(&(PHAR_G(phar_alias_map)), new_alias))) { if (SUCCESS != phar_free_alias(fd_ptr)) { - zend_throw_exception_ex(phar_ce_PharException, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", ZSTR_VAL(new_alias), ZSTR_VAL(fd_ptr->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "alias \"%pS\" is already used for archive \"%pS\" and cannot be used for other archives", new_alias, fd_ptr->fname); RETURN_THROWS(); } } else if (!phar_validate_alias(ZSTR_VAL(new_alias), ZSTR_LEN(new_alias))) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "Invalid alias \"%s\" specified for phar \"%s\"", ZSTR_VAL(new_alias), ZSTR_VAL(phar_obj->archive->fname)); + "Invalid alias \"%pS\" specified for phar \"%pS\"", new_alias, phar_obj->archive->fname); RETURN_THROWS(); } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } if (phar_obj->archive->alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len))) { @@ -2843,7 +2843,7 @@ PHP_METHOD(Phar, setStub) if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "r|l", &zstub, &len) == SUCCESS) { zend_string *method_name = get_active_function_or_method_name(); - zend_error(E_DEPRECATED, "Calling %s(resource $stub, int $length) is deprecated", ZSTR_VAL(method_name)); + zend_error(E_DEPRECATED, "Calling %pS(resource $stub, int $length) is deprecated", method_name); zend_string_release(method_name); if (UNEXPECTED(EG(exception))) { RETURN_THROWS(); @@ -2851,7 +2851,7 @@ PHP_METHOD(Phar, setStub) if ((php_stream_from_zval_no_verify(stream, zstub)) != NULL) { if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } @@ -2863,7 +2863,7 @@ PHP_METHOD(Phar, setStub) } if (stub_file_content == NULL) { - zend_throw_exception_ex(phar_ce_PharException, 0, "unable to read resource to copy stub to new phar \"%s\"", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "unable to read resource to copy stub to new phar \"%pS\"", phar_obj->archive->fname); RETURN_THROWS(); } @@ -2881,7 +2881,7 @@ PHP_METHOD(Phar, setStub) } } else if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &stub) == SUCCESS) { if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } phar_flush_ex(phar_obj->archive, stub, /* is_default_stub */ false, &error); @@ -2962,7 +2962,7 @@ PHP_METHOD(Phar, setDefaultStub) } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } phar_flush_ex(phar_obj->archive, stub, /* is_default_stub */ true, &error); @@ -3013,7 +3013,7 @@ PHP_METHOD(Phar, setSignatureAlgorithm) case PHAR_SIG_OPENSSL_SHA256: case PHAR_SIG_OPENSSL_SHA512: if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } phar_obj->archive->sig_flags = (uint32_t)algo; @@ -3323,7 +3323,7 @@ PHP_METHOD(Phar, compressFiles) } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } pharobj_set_compression(&phar_obj->archive->manifest, flags); @@ -3362,7 +3362,7 @@ PHP_METHOD(Phar, decompressFiles) RETURN_TRUE; } else { if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } pharobj_set_compression(&phar_obj->archive->manifest, PHAR_ENT_COMPRESSED_NONE); @@ -3397,35 +3397,35 @@ PHP_METHOD(Phar, copy) if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "Cannot copy \"%s\" to \"%s\", phar is read-only", ZSTR_VAL(old_file), ZSTR_VAL(new_file)); + "Cannot copy \"%pS\" to \"%pS\", phar is read-only", old_file, new_file); RETURN_THROWS(); } if (phar_is_magic_phar(old_file)) { /* can't copy a meta file */ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "file \"%s\" cannot be copied to file \"%s\", cannot copy Phar meta-file in %s", ZSTR_VAL(old_file), ZSTR_VAL(new_file), ZSTR_VAL(phar_obj->archive->fname)); + "file \"%pS\" cannot be copied to file \"%pS\", cannot copy Phar meta-file in %pS", old_file, new_file, phar_obj->archive->fname); RETURN_THROWS(); } if (phar_is_magic_phar(new_file)) { /* can't copy a meta file */ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "file \"%s\" cannot be copied to file \"%s\", cannot copy to Phar meta-file in %s", ZSTR_VAL(old_file), ZSTR_VAL(new_file), ZSTR_VAL(phar_obj->archive->fname)); + "file \"%pS\" cannot be copied to file \"%pS\", cannot copy to Phar meta-file in %pS", old_file, new_file, phar_obj->archive->fname); RETURN_THROWS(); } phar_entry_info *oldentry = zend_hash_find_ptr(&phar_obj->archive->manifest, old_file); if (!oldentry || oldentry->is_deleted) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "file \"%s\" cannot be copied to file \"%s\", file does not exist in %s", ZSTR_VAL(old_file), ZSTR_VAL(new_file), ZSTR_VAL(phar_obj->archive->fname)); + "file \"%pS\" cannot be copied to file \"%pS\", file does not exist in %pS", old_file, new_file, phar_obj->archive->fname); RETURN_THROWS(); } const phar_entry_info *temp = zend_hash_find_ptr(&phar_obj->archive->manifest, new_file); if (temp && !temp->is_deleted) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "file \"%s\" cannot be copied to file \"%s\", file must not already exist in phar %s", ZSTR_VAL(old_file), ZSTR_VAL(new_file), ZSTR_VAL(phar_obj->archive->fname)); + "file \"%pS\" cannot be copied to file \"%pS\", file must not already exist in phar %pS", old_file, new_file, phar_obj->archive->fname); RETURN_THROWS(); } @@ -3433,13 +3433,13 @@ PHP_METHOD(Phar, copy) char *tmp_new_file = ZSTR_VAL(new_file); if (phar_path_check(&tmp_new_file, &tmp_len, &pcr_error) > pcr_is_ok) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "file \"%s\" contains invalid characters %s, cannot be copied from \"%s\" in phar %s", ZSTR_VAL(new_file), pcr_error, ZSTR_VAL(old_file), ZSTR_VAL(phar_obj->archive->fname)); + "file \"%pS\" contains invalid characters %s, cannot be copied from \"%pS\" in phar %pS", new_file, pcr_error, old_file, phar_obj->archive->fname); RETURN_THROWS(); } if (phar_obj->archive->is_persistent) { if (FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } /* re-populate with copied-on-write entry */ @@ -3521,7 +3521,7 @@ PHP_METHOD(Phar, offsetGet) /* security is 0 here so that we can get a better error message than "entry doesn't exist" */ phar_entry_info *entry = phar_get_entry_info_dir(phar_obj->archive, ZSTR_VAL(file_name), ZSTR_LEN(file_name), 1, &error, false); if (!entry) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist%s%s", ZSTR_VAL(file_name), error?", ":"", error?error:""); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %pS does not exist%s%s", file_name, error?", ":"", error?error:""); } else { if (entry->is_temp_dir) { zend_string_efree(entry->filename); @@ -3529,12 +3529,12 @@ PHP_METHOD(Phar, offsetGet) } if (zend_string_equals_literal(file_name, ".phar/stub.php")) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot get stub \".phar/stub.php\" directly in phar \"%s\", use getStub", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot get stub \".phar/stub.php\" directly in phar \"%pS\", use getStub", phar_obj->archive->fname); RETURN_THROWS(); } if (zend_string_equals_literal(file_name, ".phar/alias.txt")) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot get alias \".phar/alias.txt\" directly in phar \"%s\", use getAlias", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot get alias \".phar/alias.txt\" directly in phar \"%pS\", use getAlias", phar_obj->archive->fname); RETURN_THROWS(); } @@ -3543,7 +3543,7 @@ PHP_METHOD(Phar, offsetGet) RETURN_THROWS(); } - zend_string *sfname = strpprintf(0, "phar://%s/%s", ZSTR_VAL(phar_obj->archive->fname), ZSTR_VAL(file_name)); + zend_string *sfname = strpprintf(0, "phar://%pS/%pS", phar_obj->archive->fname, file_name); zval zfname; ZVAL_NEW_STR(&zfname, sfname); @@ -3663,10 +3663,10 @@ static void phar_mkdir(phar_archive_data **pphar, zend_string *dir_name) ); if (!data) { if (error) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %s does not exist and cannot be created: %s", ZSTR_VAL(dir_name), error); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %pS does not exist and cannot be created: %s", dir_name, error); efree(error); } else { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %s does not exist and cannot be created", ZSTR_VAL(dir_name)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %pS does not exist and cannot be created", ZSTR_VAL(dir_name)); } return; @@ -3706,12 +3706,12 @@ PHP_METHOD(Phar, offsetSet) } if (zend_string_equals_literal(file_name, ".phar/stub.php")) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set stub \".phar/stub.php\" directly in phar \"%s\", use setStub", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set stub \".phar/stub.php\" directly in phar \"%pS\", use setStub", phar_obj->archive->fname); RETURN_THROWS(); } if (zend_string_equals_literal(file_name, ".phar/alias.txt")) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set alias \".phar/alias.txt\" directly in phar \"%s\", use setAlias", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set alias \".phar/alias.txt\" directly in phar \"%pS\", use setAlias", phar_obj->archive->fname); RETURN_THROWS(); } @@ -3750,7 +3750,7 @@ PHP_METHOD(Phar, offsetUnset) if (phar_obj->archive->is_persistent) { if (FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } /* re-populate entry after copy on write */ @@ -3804,13 +3804,13 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); if (!strstr(ZSTR_VAL(file_name), "://") && php_check_open_basedir(ZSTR_VAL(file_name))) { - zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%s\" to add to phar archive, open_basedir restrictions prevent this", ZSTR_VAL(file_name)); + zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%pS\" to add to phar archive, open_basedir restrictions prevent this", file_name); RETURN_THROWS(); } php_stream *resource = php_stream_open_wrapper(ZSTR_VAL(file_name), "rb", 0, NULL); if (!resource) { - zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%s\" to add to phar archive", ZSTR_VAL(file_name)); + zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%pS\" to add to phar archive", file_name); RETURN_THROWS(); } @@ -3861,7 +3861,7 @@ PHP_METHOD(Phar, getStub) } else { fp = php_stream_open_wrapper(ZSTR_VAL(phar_obj->archive->fname), "rb", 0, NULL); if (!fp) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to open phar \"%s\"", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to open phar \"%pS\"", phar_obj->archive->fname); RETURN_THROWS(); } if (stub->flags & PHAR_ENT_COMPRESSION_MASK) { @@ -3869,7 +3869,7 @@ PHP_METHOD(Phar, getStub) ZEND_ASSERT(decompression_filter_name && "Must have as this has a decompression flag set"); filter = php_stream_filter_create(decompression_filter_name, NULL, php_stream_is_persistent(fp)); if (UNEXPECTED(filter == NULL)) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to read stub of phar \"%s\" (cannot create %s filter)", ZSTR_VAL(phar_obj->archive->fname), decompression_filter_name); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to read stub of phar \"%pS\" (cannot create %s filter)", phar_obj->archive->fname, decompression_filter_name); RETURN_THROWS(); } php_stream_filter_append(&fp->readfilters, filter); @@ -4012,7 +4012,7 @@ PHP_METHOD(Phar, setMetadata) } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar_obj->archive->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } @@ -4296,7 +4296,7 @@ PHP_METHOD(Phar, extractTo) if (!fp) { zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, - "Invalid argument, %s cannot be found", ZSTR_VAL(phar_obj->archive->fname)); + "Invalid argument, %pS cannot be found", phar_obj->archive->fname); RETURN_THROWS(); } @@ -4317,12 +4317,12 @@ PHP_METHOD(Phar, extractTo) ret = php_stream_mkdir(ZSTR_VAL(path_to), 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); if (!ret) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, - "Unable to create path \"%s\" for extraction", ZSTR_VAL(path_to)); + "Unable to create path \"%pS\" for extraction", path_to); RETURN_THROWS(); } } else if (!(ssb.sb.st_mode & S_IFDIR)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, - "Unable to use path \"%s\" for extraction, it is a file, must be a directory", ZSTR_VAL(path_to)); + "Unable to use path \"%pS\" for extraction, it is a file, must be a directory", path_to); RETURN_THROWS(); } @@ -4340,14 +4340,14 @@ PHP_METHOD(Phar, extractTo) } switch (extract_helper(phar_obj->archive, Z_STR_P(zval_file), path_to, overwrite, &error)) { case -1: - zend_throw_exception_ex(phar_ce_PharException, 0, "Extraction from phar \"%s\" failed: %s", - ZSTR_VAL(phar_obj->archive->fname), error); + zend_throw_exception_ex(phar_ce_PharException, 0, "Extraction from phar \"%pS\" failed: %s", + phar_obj->archive->fname, error); efree(error); RETURN_THROWS(); case 0: zend_throw_exception_ex(phar_ce_PharException, 0, - "phar error: attempted to extract non-existent file or directory \"%s\" from phar \"%s\"", - ZSTR_VAL(Z_STR_P(zval_file)), ZSTR_VAL(phar_obj->archive->fname)); + "phar error: attempted to extract non-existent file or directory \"%pS\" from phar \"%pS\"", + Z_STR_P(zval_file), phar_obj->archive->fname); RETURN_THROWS(); } } ZEND_HASH_FOREACH_END(); @@ -4356,13 +4356,13 @@ PHP_METHOD(Phar, extractTo) ret = extract_helper(phar_obj->archive, filename, path_to, overwrite, &error); if (-1 == ret) { - zend_throw_exception_ex(phar_ce_PharException, 0, "Extraction from phar \"%s\" failed: %s", - ZSTR_VAL(phar_obj->archive->fname), error); + zend_throw_exception_ex(phar_ce_PharException, 0, "Extraction from phar \"%pS\" failed: %s", + phar_obj->archive->fname, error); efree(error); } else if (0 == ret && NULL != filename) { zend_throw_exception_ex(phar_ce_PharException, 0, - "phar error: attempted to extract non-existent file or directory \"%s\" from phar \"%s\"", - ZSTR_VAL(filename), ZSTR_VAL(phar_obj->archive->fname)); + "phar error: attempted to extract non-existent file or directory \"%pS\" from phar \"%pS\"", + filename, phar_obj->archive->fname); } else { RETURN_TRUE; } @@ -4421,8 +4421,8 @@ PHP_METHOD(PharFileInfo, __construct) phar_entry_info *entry_info = phar_get_entry_info_dir(phar_data, ZSTR_VAL(entry), ZSTR_LEN(entry), 1, &error, true); if (UNEXPECTED(!entry_info)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, - "Cannot access phar file entry '%s' in archive '%s'%s%s", - ZSTR_VAL(entry), ZSTR_VAL(arch), error ? ", " : "", error ? error : ""); + "Cannot access phar file entry '%pS' in archive '%pS'%s%s", + entry, arch, error ? ", " : "", error ? error : ""); zend_string_release_ex(entry, false); zend_string_release_ex(arch, false); RETURN_THROWS(); @@ -4586,12 +4586,12 @@ PHP_METHOD(PharFileInfo, chmod) if (entry_obj->entry->is_temp_dir) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \ - "Phar entry \"%s\" is a temporary directory (not an actual entry in the archive), cannot chmod", ZSTR_VAL(entry_obj->entry->filename)); \ + "Phar entry \"%pS\" is a temporary directory (not an actual entry in the archive), cannot chmod", entry_obj->entry->filename); \ RETURN_THROWS(); } if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) { - zend_throw_exception_ex(phar_ce_PharException, 0, "Cannot modify permissions for file \"%s\" in phar \"%s\", write operations are prohibited", ZSTR_VAL(entry_obj->entry->filename), ZSTR_VAL(entry_obj->entry->phar->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "Cannot modify permissions for file \"%pS\" in phar \"%pS\", write operations are prohibited", entry_obj->entry->filename, entry_obj->entry->phar->fname); RETURN_THROWS(); } @@ -4599,7 +4599,7 @@ PHP_METHOD(PharFileInfo, chmod) phar_archive_data *phar = entry_obj->entry->phar; if (FAILURE == phar_copy_on_write(&phar)) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar->fname); RETURN_THROWS(); } /* re-populate after copy-on-write */ @@ -4692,7 +4692,7 @@ PHP_METHOD(PharFileInfo, setMetadata) phar_archive_data *phar = entry_obj->entry->phar; if (FAILURE == phar_copy_on_write(&phar)) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar->fname); RETURN_THROWS(); } /* re-populate after copy-on-write */ @@ -4740,7 +4740,7 @@ PHP_METHOD(PharFileInfo, delMetadata) phar_archive_data *phar = entry_obj->entry->phar; if (FAILURE == phar_copy_on_write(&phar)) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar->fname); RETURN_THROWS(); } /* re-populate after copy-on-write */ @@ -4780,7 +4780,7 @@ PHP_METHOD(PharFileInfo, getContent) if (entry_obj->entry->is_dir) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "phar error: Cannot retrieve contents, \"%s\" in phar \"%s\" is a directory", ZSTR_VAL(entry_obj->entry->filename), ZSTR_VAL(entry_obj->entry->phar->fname)); + "phar error: Cannot retrieve contents, \"%pS\" in phar \"%pS\" is a directory", entry_obj->entry->filename, entry_obj->entry->phar->fname); RETURN_THROWS(); } @@ -4792,7 +4792,7 @@ PHP_METHOD(PharFileInfo, getContent) if (SUCCESS != phar_open_entry_fp(link, &error, false)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "phar error: Cannot retrieve contents, \"%s\" in phar \"%s\": %s", ZSTR_VAL(entry_obj->entry->filename), ZSTR_VAL(entry_obj->entry->phar->fname), error); + "phar error: Cannot retrieve contents, \"%pS\" in phar \"%pS\": %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error); efree(error); RETURN_THROWS(); } @@ -4800,7 +4800,7 @@ PHP_METHOD(PharFileInfo, getContent) php_stream *fp = phar_get_efp(link, false); if (!fp) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "phar error: Cannot retrieve contents of \"%s\" in phar \"%s\"", ZSTR_VAL(entry_obj->entry->filename), ZSTR_VAL(entry_obj->entry->phar->fname)); + "phar error: Cannot retrieve contents of \"%pS\" in phar \"%pS\"", entry_obj->entry->filename, entry_obj->entry->phar->fname); RETURN_THROWS(); } @@ -4854,7 +4854,7 @@ PHP_METHOD(PharFileInfo, compress) phar_archive_data *phar = entry_obj->entry->phar; if (FAILURE == phar_copy_on_write(&phar)) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar->fname); RETURN_THROWS(); } /* re-populate after copy-on-write */ @@ -4876,7 +4876,7 @@ PHP_METHOD(PharFileInfo, compress) /* decompress this file indirectly */ if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, true)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "phar error: Cannot decompress bzip2-compressed file \"%s\" in phar \"%s\" in order to compress with gzip: %s", ZSTR_VAL(entry_obj->entry->filename), ZSTR_VAL(entry_obj->entry->phar->fname), error); + "phar error: Cannot decompress bzip2-compressed file \"%pS\" in phar \"%pS\" in order to compress with gzip: %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error); efree(error); RETURN_THROWS(); } @@ -4907,7 +4907,7 @@ PHP_METHOD(PharFileInfo, compress) /* decompress this file indirectly */ if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, true)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "phar error: Cannot decompress gzip-compressed file \"%s\" in phar \"%s\" in order to compress with bzip2: %s", ZSTR_VAL(entry_obj->entry->filename), ZSTR_VAL(entry_obj->entry->phar->fname), error); + "phar error: Cannot decompress gzip-compressed file \"%pS\" in phar \"%pS\" in order to compress with bzip2: %s", entry_obj->entry->filename, entry_obj->entry->phar->fname, error); efree(error); RETURN_THROWS(); } @@ -4989,7 +4989,7 @@ PHP_METHOD(PharFileInfo, decompress) phar_archive_data *phar = entry_obj->entry->phar; if (FAILURE == phar_copy_on_write(&phar)) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", ZSTR_VAL(phar->fname)); + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%pS\" is persistent, unable to copy on write", phar->fname); RETURN_THROWS(); } /* re-populate after copy-on-write */ @@ -5010,7 +5010,7 @@ PHP_METHOD(PharFileInfo, decompress) /* decompress this file indirectly */ if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, true)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, - "Phar error: Cannot decompress %s-compressed file \"%s\" in phar \"%s\": %s", compression_type, ZSTR_VAL(entry_obj->entry->filename), ZSTR_VAL(entry_obj->entry->phar->fname), error); + "Phar error: Cannot decompress %s-compressed file \"%pS\" in phar \"%pS\": %s", compression_type, entry_obj->entry->filename, entry_obj->entry->phar->fname, error); efree(error); RETURN_THROWS(); } diff --git a/ext/phar/stream.c b/ext/phar/stream.c index 9474498e3892..20c49780dacd 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -203,7 +203,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha efree(error); } else { php_stream_wrapper_log_warn(wrapper, context, options, CreateFailed, - "phar error: file \"%s\" could not be created in phar \"%s\"", internal_file, ZSTR_VAL(resource->host)); + "phar error: file \"%s\" could not be created in phar \"%pS\"", internal_file, resource->host); } efree(internal_file); php_url_free(resource); @@ -234,7 +234,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha } } if (opened_path) { - *opened_path = zend_strpprintf_unchecked(MAXPATHLEN, "phar://%S/%S", idata->phar->fname, idata->internal_file->filename); + *opened_path = zend_strpprintf(MAXPATHLEN, "phar://%pS/%pS", idata->phar->fname, idata->internal_file->filename); } return fpf; } else { @@ -243,7 +243,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha phar = phar_get_archive(ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), NULL, 0, NULL); if (!phar) { php_stream_wrapper_log_warn(wrapper, context, options, InvalidFormat, - "file %s is not a valid phar archive", ZSTR_VAL(resource->host)); + "file %pS is not a valid phar archive", resource->host); efree(internal_file); php_url_free(resource); return NULL; @@ -264,7 +264,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha stream = phar_open_archive_fp(phar); if (UNEXPECTED(!stream)) { php_stream_wrapper_log_warn(wrapper, context, options, OpenFailed, - "phar error: could not reopen phar \"%s\"", ZSTR_VAL(resource->host)); + "phar error: could not reopen phar \"%pS\"", resource->host); efree(internal_file); php_url_free(resource); return NULL; @@ -305,7 +305,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha efree(error); } else { php_stream_wrapper_log_warn(wrapper, context, options, NotFound, - "phar error: \"%s\" is not a file in phar \"%s\"", internal_file, ZSTR_VAL(resource->host)); + "phar error: \"%s\" is not a file in phar \"%pS\"", internal_file, resource->host); } efree(internal_file); php_url_free(resource); @@ -347,7 +347,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha } } if (opened_path) { - *opened_path = zend_strpprintf_unchecked(MAXPATHLEN, "phar://%S/%S", idata->phar->fname, idata->internal_file->filename); + *opened_path = zend_strpprintf(MAXPATHLEN, "phar://%pS/%pS", idata->phar->fname, idata->internal_file->filename); } efree(internal_file); phar_stub: @@ -455,8 +455,8 @@ static ssize_t phar_stream_write(php_stream *stream, const char *buf, size_t cou php_stream_seek(data->fp, data->position + data->zero, SEEK_SET); if (count != php_stream_write(data->fp, buf, count)) { php_stream_warn(stream, WriteFailed, - "phar error: Could not write %zu characters to \"%s\" in phar \"%s\"", - count, ZSTR_VAL(data->internal_file->filename), ZSTR_VAL(data->phar->fname)); + "phar error: Could not write %zu characters to \"%pS\" in phar \"%pS\"", + count, data->internal_file->filename, data->phar->fname); return -1; } data->position = php_stream_tell(data->fp) - data->zero; @@ -727,8 +727,8 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int if (idata->internal_file->fp_refcount > 1) { /* more than just our fp resource is open for this file */ php_stream_wrapper_log_warn(wrapper, context, options, UnlinkFailed, - "phar error: \"%s\" in phar \"%s\", has open file pointers, cannot unlink", - internal_file, ZSTR_VAL(resource->host)); + "phar error: \"%s\" in phar \"%pS\", has open file pointers, cannot unlink", + internal_file, resource->host); efree(internal_file); php_url_free(resource); phar_entry_delref(idata); diff --git a/ext/phar/tar.c b/ext/phar/tar.c index bc78472afce3..03d25dea7ee6 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -939,7 +939,7 @@ ZEND_ATTRIBUTE_NONNULL static int phar_tar_setupmetadata(zval *zv, void *argumen } /* now we are dealing with regular files, so look for metadata */ - zend_string *lookfor = zend_strpprintf_unchecked(0, ".phar/.metadata/%S/.metadata.bin", entry->filename); + zend_string *lookfor = zend_strpprintf(0, ".phar/.metadata/%pS/.metadata.bin", entry->filename); if (!phar_metadata_tracker_has_data(&entry->metadata_tracker, entry->is_persistent)) { zend_hash_del(&entry->phar->manifest, lookfor); diff --git a/ext/phar/util.c b/ext/phar/util.c index b93bf6940dea..18300f7e9adc 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -350,7 +350,7 @@ splitted:; } } else { if (zend_hash_exists(&(phar->manifest), test)) { - ret = strpprintf(0, "phar://%s/%s", ZSTR_VAL(arch), ZSTR_VAL(test)); + ret = strpprintf(0, "phar://%pS/%pS", arch, test); zend_string_release_ex(test, false); zend_string_release_ex(arch, false); return ret; @@ -359,7 +359,7 @@ splitted:; zend_string_release_ex(test, false); } - spprintf(&path, MAXPATHLEN + 1 + strlen(PG(include_path)), "phar://%s/%s%c%s", ZSTR_VAL(arch), PHAR_G(cwd), DEFAULT_DIR_SEPARATOR, PG(include_path)); + spprintf(&path, MAXPATHLEN + 1 + strlen(PG(include_path)), "phar://%pS/%s%c%s", arch, PHAR_G(cwd), DEFAULT_DIR_SEPARATOR, PG(include_path)); zend_string_release_ex(arch, false); ret = php_resolve_path(ZSTR_VAL(filename), ZSTR_LEN(filename), path); efree(path);