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
18 changes: 9 additions & 9 deletions Zend/zend_attributes.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static zend_object_handlers attributes_object_handlers_sensitive_parameter_value

static HashTable internal_attributes;

uint32_t zend_attribute_attribute_get_flags(zend_attribute *attr, zend_class_entry *scope)
uint32_t zend_attribute_attribute_get_flags(const zend_attribute *attr, zend_class_entry *scope)
{
// TODO: More proper signature validation: Too many args, incorrect arg names.
if (attr->argc > 0) {
Expand Down Expand Up @@ -265,7 +265,7 @@ ZEND_METHOD(NoDiscard, __construct)
}
}

static zend_attribute *get_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset)
static zend_attribute *get_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset)
{
if (attributes) {
zend_attribute *attr;
Expand All @@ -280,7 +280,7 @@ static zend_attribute *get_attribute(HashTable *attributes, zend_string *lcname,
return NULL;
}

static zend_attribute *get_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset)
static zend_attribute *get_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset)
{
if (attributes) {
zend_attribute *attr;
Expand All @@ -295,27 +295,27 @@ static zend_attribute *get_attribute_str(HashTable *attributes, const char *str,
return NULL;
}

ZEND_API zend_attribute *zend_get_attribute(HashTable *attributes, zend_string *lcname)
ZEND_API zend_attribute *zend_get_attribute(const HashTable *attributes, const zend_string *lcname)
{
return get_attribute(attributes, lcname, 0);
}

ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len)
ZEND_API zend_attribute *zend_get_attribute_str(const HashTable *attributes, const char *str, size_t len)
{
return get_attribute_str(attributes, str, len, 0);
}

ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset)
ZEND_API zend_attribute *zend_get_parameter_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset)
{
return get_attribute(attributes, lcname, offset + 1);
}

ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset)
ZEND_API zend_attribute *zend_get_parameter_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset)
{
return get_attribute_str(attributes, str, len, offset + 1);
}

ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope)
ZEND_API zend_result zend_get_attribute_value(zval *ret, const zend_attribute *attr, uint32_t i, zend_class_entry *scope)
{
if (i >= attr->argc) {
return FAILURE;
Expand Down Expand Up @@ -447,7 +447,7 @@ ZEND_API zend_string *zend_get_attribute_target_names(uint32_t flags)
return smart_str_extract(&str);
}

ZEND_API bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr)
ZEND_API bool zend_is_attribute_repeated(const HashTable *attributes, const zend_attribute *attr)
{
zend_attribute *other;

Expand Down
18 changes: 9 additions & 9 deletions Zend/zend_attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ typedef struct _zend_internal_attribute {
zend_string* (*validator)(zend_attribute *attr, uint32_t target, zend_class_entry *scope);
} zend_internal_attribute;

ZEND_API zend_attribute *zend_get_attribute(HashTable *attributes, zend_string *lcname);
ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len);
ZEND_API zend_attribute *zend_get_attribute(const HashTable *attributes, const zend_string *lcname);
ZEND_API zend_attribute *zend_get_attribute_str(const HashTable *attributes, const char *str, size_t len);

ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset);
ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset);
ZEND_API zend_attribute *zend_get_parameter_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset);
ZEND_API zend_attribute *zend_get_parameter_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset);

ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope);
ZEND_API zend_result zend_get_attribute_value(zval *ret, const zend_attribute *attr, uint32_t i, zend_class_entry *scope);
ZEND_API zend_result zend_get_attribute_object(zval *out, zend_class_entry *attribute_ce, zend_attribute *attribute_data, zend_class_entry *scope, zend_string *filename);

ZEND_API zend_string *zend_get_attribute_target_names(uint32_t targets);
ZEND_API bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr);
ZEND_API bool zend_is_attribute_repeated(const HashTable *attributes, const zend_attribute *attr);

ZEND_API zend_internal_attribute *zend_mark_internal_attribute(zend_class_entry *ce);
ZEND_API zend_internal_attribute *zend_internal_attribute_register(zend_class_entry *ce, uint32_t flags);
Expand All @@ -97,7 +97,7 @@ ZEND_API zend_attribute *zend_add_attribute(
HashTable **attributes, zend_string *name, uint32_t argc,
uint32_t flags, uint32_t offset, uint32_t lineno);

uint32_t zend_attribute_attribute_get_flags(zend_attribute *attr, zend_class_entry *scope);
uint32_t zend_attribute_attribute_get_flags(const zend_attribute *attr, zend_class_entry *scope);

END_EXTERN_C()

Expand All @@ -119,13 +119,13 @@ static zend_always_inline zend_attribute *zend_add_parameter_attribute(zend_func
return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0);
}

static zend_always_inline zend_attribute *zend_add_property_attribute(zend_class_entry *ce, zend_property_info *info, zend_string *name, uint32_t argc)
static zend_always_inline zend_attribute *zend_add_property_attribute(const zend_class_entry *ce, zend_property_info *info, zend_string *name, uint32_t argc)
{
uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
return zend_add_attribute(&info->attributes, name, argc, flags, 0, 0);
}

static zend_always_inline zend_attribute *zend_add_class_constant_attribute(zend_class_entry *ce, zend_class_constant *c, zend_string *name, uint32_t argc)
static zend_always_inline zend_attribute *zend_add_class_constant_attribute(const zend_class_entry *ce, zend_class_constant *c, zend_string *name, uint32_t argc)
{
uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0;
return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0);
Expand Down
14 changes: 14 additions & 0 deletions ext/dom/tests/DOMXPath_callables_errors.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ try {
echo $e->getMessage(), "\n";
}

$x = new class {
public static function dump() {}
};

$classes = get_declared_classes();

try {
$str = str_repeat($classes[count($classes) - 1] . '::dump', random_int(1, 1));
$xpath->registerPhpFunctions([$str]);
} catch (Throwable $e) {
echo $e->getMessage(), "\n";
}

?>
--EXPECT--
DOMXPath::registerPhpFunctions(): Argument #1 ($restrict) must be a callable, function "nonexistent" not found or invalid function name
Expand All @@ -67,3 +80,4 @@ DOMXPath::registerPhpFunctions(): Argument #1 ($restrict) must be an array with
DOMXPath::registerPhpFunctions(): Argument #1 ($restrict) must be an array containing valid callback names
DOMXPath::registerPhpFunctions(): Argument #1 ($restrict) must be an array containing valid callback names
DOMXPath::registerPhpFunctions(): Argument #1 ($restrict) must be a valid callback name
DOMXPath::registerPhpFunctions(): Argument #1 ($restrict) must be an array containing valid callback names
1 change: 1 addition & 0 deletions ext/dom/xpath_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ static zend_result php_dom_xpath_callback_ns_update_method_handler(
}
zend_tmp_string_release(tmp_str);
} else {
zend_tmp_string_release(tmp_str);
zend_fcc_dtor(fcc);
efree(fcc);
return FAILURE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ var_dump($uri2->toString());
--EXPECT--
string(11) "example.com"
NULL
string(7) "https:/"
string(6) "https:"
NULL
string(7) "https:/"
string(6) "https:"
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(0) ""
string(21) "https://example.com/#"
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(0) ""
string(21) "https://example.com/?"
6 changes: 3 additions & 3 deletions ext/uri/uri_parser_whatwg.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ static zend_result php_uri_parser_whatwg_path_read(void *uri, php_uri_component_
{
const lxb_url_t *lexbor_uri = uri;

if (lexbor_uri->path.str.length) {
if (lexbor_uri->path.str.length > 0) {
ZVAL_STRINGL(retval, (const char *) lexbor_uri->path.str.data, lexbor_uri->path.str.length);
} else {
ZVAL_EMPTY_STRING(retval);
Expand Down Expand Up @@ -460,7 +460,7 @@ static zend_result php_uri_parser_whatwg_query_read(void *uri, php_uri_component
{
const lxb_url_t *lexbor_uri = uri;

if (lexbor_uri->query.length) {
if (lexbor_uri->query.data != NULL) {
ZVAL_STRINGL(retval, (const char *) lexbor_uri->query.data, lexbor_uri->query.length);
} else {
ZVAL_NULL(retval);
Expand Down Expand Up @@ -489,7 +489,7 @@ static zend_result php_uri_parser_whatwg_fragment_read(void *uri, php_uri_compon
{
const lxb_url_t *lexbor_uri = uri;

if (lexbor_uri->fragment.length) {
if (lexbor_uri->fragment.data != NULL) {
ZVAL_STRINGL(retval, (const char *) lexbor_uri->fragment.data, lexbor_uri->fragment.length);
} else {
ZVAL_NULL(retval);
Expand Down
Loading