diff --git a/NEWS b/NEWS index 5c6f6e8db9e3..c1bf79e07fba 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ PHP NEWS n_scale. (Ilia Alshanetsky) - Core: + . Fixed out-of-bounds reads during automatic UTF-16/32 encoding detection. + (Yudai Takada) . Calling is_a() or is_subclass_of() with a string as the first argument when $allow_string is false is now deprecated. (Daniel Scherzer) . Fixed bug GH-23232 (lone namespace separator asks the autoloader for an diff --git a/Zend/tests/multibyte/multibyte_encoding_008.phpt b/Zend/tests/multibyte/multibyte_encoding_008.phpt new file mode 100644 index 000000000000..69a2aa58369a --- /dev/null +++ b/Zend/tests/multibyte/multibyte_encoding_008.phpt @@ -0,0 +1,20 @@ +--TEST-- +Zend Multibyte does not read past the script during UTF-16 detection +--EXTENSIONS-- +mbstring +--INI-- +zend.multibyte=1 +internal_encoding=UTF-8 +--FILE-- + +--CLEAN-- + +--EXPECT-- +Done diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index bf6bbe7f9d90..60143bc800fe 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -332,14 +332,13 @@ ZEND_API zend_result zend_lex_tstring(zval *zv, unsigned char *ident) static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned char *script, size_t script_size) { const unsigned char *p; + size_t offset = 0; int wchar_size = 2; int le = 0; /* utf-16 or utf-32? */ - p = script; - assert(p >= script); - while ((size_t)(p-script) < script_size) { - p = memchr(p, 0, script_size-(p-script)-2); + while (offset < script_size && script_size - offset > 2) { + p = memchr(script + offset, 0, script_size - offset - 2); if (!p) { break; } @@ -349,13 +348,13 @@ static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned ch } /* searching for UTF-32 specific byte orders, so this will do */ - p += 4; + offset = p - script + 4; } /* BE or LE? */ - p = script; - assert(p >= script); - while ((size_t)(p-script) < script_size) { + offset = 0; + while (script_size - offset >= (size_t) wchar_size) { + p = script + offset; if (*p == '\0' && *(p+wchar_size-1) != '\0') { /* BE */ le = 0; @@ -365,7 +364,7 @@ static const zend_encoding *zend_multibyte_detect_utf_encoding(const unsigned ch le = 1; break; } - p += wchar_size; + offset += wchar_size; } if (wchar_size == 2) { diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 94b7d803a030..0c0607392366 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -1158,7 +1158,8 @@ static bool snmp_session_set_contextEngineID(struct snmp_session *s, zend_string size_t ebuf_len = 32, eout_len = 0; uint8_t *ebuf = (uint8_t *) emalloc(ebuf_len); - if (!snmp_hex_to_binary(&ebuf, &ebuf_len, &eout_len, 1, ZSTR_VAL(contextEngineID))) { + /* Disallow reallocation: ebuf comes from emalloc() and net-snmp would realloc() it. */ + if (!snmp_hex_to_binary(&ebuf, &ebuf_len, &eout_len, 0, ZSTR_VAL(contextEngineID))) { zend_argument_value_error(context_engine_id_arg_num, "must be a valid context engine ID"); efree(ebuf); return false; diff --git a/ext/snmp/tests/gh23453.phpt b/ext/snmp/tests/gh23453.phpt new file mode 100644 index 000000000000..19327791fa9a --- /dev/null +++ b/ext/snmp/tests/gh23453.phpt @@ -0,0 +1,19 @@ +--TEST-- +GH-23453 (SNMP::setSecurity() frees a non-malloced address with a context engine ID longer than 32 bytes) +--EXTENSIONS-- +snmp +--FILE-- +setSecurity('authPriv', 'SHA', 'authpassword12345', 'AES', 'privpassword12345', 'myContext', str_repeat('aa', 32))); +try { + var_dump($session->setSecurity('authPriv', 'SHA', 'authpassword12345', 'AES', 'privpassword12345', 'myContext', str_repeat('aa', 33))); +} catch (\ValueError $e) { + echo $e::class, ': ', $e->getMessage(), \PHP_EOL; +} +?> +--EXPECT-- +bool(true) +ValueError: SNMP::setSecurity(): Argument #7 ($contextEngineId) must be a valid context engine ID diff --git a/ext/uri/php_uri.c b/ext/uri/php_uri.c index 5f343240bbf6..457e123bb489 100644 --- a/ext/uri/php_uri.c +++ b/ext/uri/php_uri.c @@ -1088,31 +1088,31 @@ PHP_FUNCTION(Uri_WhatWg_url_percent_encode) case ZEND_ENUM_Uri_WhatWg_UrlPercentEncodingMode_Username: ZEND_FALLTHROUGH; case ZEND_ENUM_Uri_WhatWg_UrlPercentEncodingMode_Password: - str = php_uri_parser_whatwg_percent_encode_userinfo_component(ZSTR_VAL(input), ZSTR_LEN(input)); + str = php_uri_parser_whatwg_userinfo_percent_encode(ZSTR_VAL(input), ZSTR_LEN(input)); break; case ZEND_ENUM_Uri_WhatWg_UrlPercentEncodingMode_OpaqueHost: - str = php_uri_parser_whatwg_percent_encode_opaque_host_component(ZSTR_VAL(input), ZSTR_LEN(input)); + str = php_uri_parser_whatwg_opaque_host_percent_encode(ZSTR_VAL(input), ZSTR_LEN(input)); break; case ZEND_ENUM_Uri_WhatWg_UrlPercentEncodingMode_Path: - str = php_uri_parser_whatwg_percent_encode_path_component(ZSTR_VAL(input), ZSTR_LEN(input)); + str = php_uri_parser_whatwg_path_percent_encode(ZSTR_VAL(input), ZSTR_LEN(input)); break; case ZEND_ENUM_Uri_WhatWg_UrlPercentEncodingMode_OpaquePath: - str = php_uri_parser_whatwg_percent_encode_opaque_path_component(ZSTR_VAL(input), ZSTR_LEN(input)); + str = php_uri_parser_whatwg_opaque_path_percent_encode(ZSTR_VAL(input), ZSTR_LEN(input)); break; case ZEND_ENUM_Uri_WhatWg_UrlPercentEncodingMode_PathSegment: - str = php_uri_parser_whatwg_percent_encode_path_segment_component(ZSTR_VAL(input), ZSTR_LEN(input)); + str = php_uri_parser_whatwg_path_segment_percent_encode(ZSTR_VAL(input), ZSTR_LEN(input)); break; case ZEND_ENUM_Uri_WhatWg_UrlPercentEncodingMode_Query: - str = php_uri_parser_whatwg_percent_encode_query_component(ZSTR_VAL(input), ZSTR_LEN(input)); + str = php_uri_parser_whatwg_query_percent_encode(ZSTR_VAL(input), ZSTR_LEN(input)); break; case ZEND_ENUM_Uri_WhatWg_UrlPercentEncodingMode_SpecialQuery: - str = php_uri_parser_whatwg_percent_encode_special_query_component(ZSTR_VAL(input), ZSTR_LEN(input)); + str = php_uri_parser_whatwg_special_query_percent_encode(ZSTR_VAL(input), ZSTR_LEN(input)); break; case ZEND_ENUM_Uri_WhatWg_UrlPercentEncodingMode_FormQuery: - str = php_uri_parser_whatwg_percent_encode_form_query_component(ZSTR_VAL(input), ZSTR_LEN(input)); + str = php_uri_parser_whatwg_form_query_percent_encode(ZSTR_VAL(input), ZSTR_LEN(input)); break; case ZEND_ENUM_Uri_WhatWg_UrlPercentEncodingMode_Fragment: - str = php_uri_parser_whatwg_percent_encode_fragment_component(ZSTR_VAL(input), ZSTR_LEN(input)); + str = php_uri_parser_whatwg_fragment_percent_encode(ZSTR_VAL(input), ZSTR_LEN(input)); break; default: ZEND_UNREACHABLE(); } @@ -1216,7 +1216,7 @@ PHP_METHOD(Uri_Rfc3986_UriBuilder, setScheme) php_uri_builder_set_component_string_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("scheme"), - php_uri_parser_rfc3986_validate_scheme + php_uri_parser_rfc3986_scheme_validate ); } @@ -1225,7 +1225,7 @@ PHP_METHOD(Uri_Rfc3986_UriBuilder, setUserInfo) php_uri_builder_set_component_string_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("userinfo"), - php_uri_parser_rfc3986_validate_userinfo + php_uri_parser_rfc3986_userinfo_validate ); } @@ -1234,7 +1234,7 @@ PHP_METHOD(Uri_Rfc3986_UriBuilder, setHost) php_uri_builder_set_component_string_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("host"), - php_uri_parser_rfc3986_validate_host + php_uri_parser_rfc3986_host_validate ); } @@ -1243,7 +1243,7 @@ PHP_METHOD(Uri_Rfc3986_UriBuilder, setPort) php_uri_builder_set_component_long_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("port"), - php_uri_parser_rfc3986_validate_port + php_uri_parser_rfc3986_port_validate ); } @@ -1252,7 +1252,7 @@ PHP_METHOD(Uri_Rfc3986_UriBuilder, setPath) php_uri_builder_set_component_string( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("path"), - php_uri_parser_rfc3986_validate_path + php_uri_parser_rfc3986_path_validate ); } @@ -1261,7 +1261,7 @@ PHP_METHOD(Uri_Rfc3986_UriBuilder, setQuery) php_uri_builder_set_component_string_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("query"), - php_uri_parser_rfc3986_validate_query + php_uri_parser_rfc3986_query_validate ); } @@ -1270,7 +1270,7 @@ PHP_METHOD(Uri_Rfc3986_UriBuilder, setFragment) php_uri_builder_set_component_string_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("fragment"), - php_uri_parser_rfc3986_validate_fragment + php_uri_parser_rfc3986_fragment_validate ); } @@ -1334,7 +1334,7 @@ PHP_METHOD(Uri_WhatWg_UrlBuilder, setScheme) php_uri_builder_set_component_string( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("scheme"), - php_uri_parser_whatwg_validate_scheme + php_uri_parser_whatwg_scheme_validate ); } @@ -1343,7 +1343,7 @@ PHP_METHOD(Uri_WhatWg_UrlBuilder, setUsername) php_uri_builder_set_component_string_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("username"), - php_uri_parser_whatwg_validate_none + php_uri_parser_whatwg_none_validate ); } @@ -1352,7 +1352,7 @@ PHP_METHOD(Uri_WhatWg_UrlBuilder, setPassword) php_uri_builder_set_component_string_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("password"), - php_uri_parser_whatwg_validate_none + php_uri_parser_whatwg_none_validate ); } @@ -1361,7 +1361,7 @@ PHP_METHOD(Uri_WhatWg_UrlBuilder, setHost) php_uri_builder_set_component_string_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("host"), - php_uri_parser_whatwg_validate_host + php_uri_parser_whatwg_host_validate ); } @@ -1370,7 +1370,7 @@ PHP_METHOD(Uri_WhatWg_UrlBuilder, setPort) php_uri_builder_set_component_long_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("port"), - php_uri_parser_whatwg_validate_port + php_uri_parser_whatwg_port_validate ); } @@ -1379,7 +1379,7 @@ PHP_METHOD(Uri_WhatWg_UrlBuilder, setPath) php_uri_builder_set_component_string( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("path"), - php_uri_parser_whatwg_validate_none + php_uri_parser_whatwg_none_validate ); } @@ -1388,7 +1388,7 @@ PHP_METHOD(Uri_WhatWg_UrlBuilder, setQuery) php_uri_builder_set_component_string_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("query"), - php_uri_parser_whatwg_validate_none + php_uri_parser_whatwg_none_validate ); } @@ -1397,7 +1397,7 @@ PHP_METHOD(Uri_WhatWg_UrlBuilder, setFragment) php_uri_builder_set_component_string_or_null( INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_STRL("fragment"), - php_uri_parser_whatwg_validate_none + php_uri_parser_whatwg_none_validate ); } diff --git a/ext/uri/uri_parser_rfc3986.c b/ext/uri/uri_parser_rfc3986.c index f4f5f2bf5bd9..20bac3b14260 100644 --- a/ext/uri/uri_parser_rfc3986.c +++ b/ext/uri/uri_parser_rfc3986.c @@ -703,7 +703,7 @@ static zend_always_inline zend_result php_uri_parser_rfc3986_validate_component_ return FAILURE; } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_scheme(const zend_string *scheme) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_scheme_validate(const zend_string *scheme) { const char *p = ZSTR_VAL(scheme); const size_t len = ZSTR_LEN(scheme); @@ -712,7 +712,7 @@ ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_scheme(const return php_uri_parser_rfc3986_validate_component_result(well_formed, "scheme"); } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_userinfo(const zend_string *userinfo) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_userinfo_validate(const zend_string *userinfo) { const char *p = ZSTR_VAL(userinfo); const size_t len = ZSTR_LEN(userinfo); @@ -721,7 +721,7 @@ ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_userinfo(cons return php_uri_parser_rfc3986_validate_component_result(well_formed, "userinfo"); } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_host(const zend_string *host) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_host_validate(const zend_string *host) { const char *p = ZSTR_VAL(host); const size_t len = ZSTR_LEN(host); @@ -758,7 +758,7 @@ ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_host(const ze ); } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_port(const zend_long port) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_port_validate(const zend_long port) { char buf[MAX_LENGTH_OF_LONG + 1]; const char *res = zend_print_long_to_buf(buf + sizeof(buf) - 1, port); @@ -768,7 +768,7 @@ ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_port(const ze return php_uri_parser_rfc3986_validate_component_result(well_formed, "port"); } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_path(const zend_string *path) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_path_validate(const zend_string *path) { const char *p = ZSTR_VAL(path); const size_t len = ZSTR_LEN(path); @@ -779,7 +779,7 @@ ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_path(const ze return php_uri_parser_rfc3986_validate_component_result(well_formed, "path"); } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_query(const zend_string *query) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_query_validate(const zend_string *query) { const char *p = ZSTR_VAL(query); const size_t len = ZSTR_LEN(query); @@ -788,7 +788,7 @@ ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_query(const z return php_uri_parser_rfc3986_validate_component_result(well_formed, "query"); } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_fragment(const zend_string *fragment) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_fragment_validate(const zend_string *fragment) { const char *p = ZSTR_VAL(fragment); const size_t len = ZSTR_LEN(fragment); diff --git a/ext/uri/uri_parser_rfc3986.h b/ext/uri/uri_parser_rfc3986.h index 9a9f0b38a0c4..838b86771257 100644 --- a/ext/uri/uri_parser_rfc3986.h +++ b/ext/uri/uri_parser_rfc3986.h @@ -29,13 +29,13 @@ zend_result php_uri_parser_rfc3986_userinfo_write(php_uri_parser_rfc3986_uris *u php_uri_parser_rfc3986_uris *php_uri_parser_rfc3986_parse_ex(const char *uri_str, size_t uri_str_len, const php_uri_parser_rfc3986_uris *uriparser_base_url, bool silent); -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_scheme(const zend_string *scheme); -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_userinfo(const zend_string *userinfo); -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_host(const zend_string *host); -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_port(zend_long port); -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_path(const zend_string *path); -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_query(const zend_string *query); -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_validate_fragment(const zend_string *fragment); +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_scheme_validate(const zend_string *scheme); +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_userinfo_validate(const zend_string *userinfo); +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_host_validate(const zend_string *host); +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_port_validate(zend_long port); +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_path_validate(const zend_string *path); +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_query_validate(const zend_string *query); +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_fragment_validate(const zend_string *fragment); ZEND_ATTRIBUTE_NONNULL_ARGS(2,3,4,5,6,7,8) php_uri_parser_rfc3986_uris *php_uri_parser_rfc3986_build_from_zval( const php_uri_parser_rfc3986_uris *uriparser_base_uris, diff --git a/ext/uri/uri_parser_whatwg.c b/ext/uri/uri_parser_whatwg.c index 4f308ba224bd..903f2568d592 100644 --- a/ext/uri/uri_parser_whatwg.c +++ b/ext/uri/uri_parser_whatwg.c @@ -675,27 +675,27 @@ static zend_string *php_uri_parser_whatwg_percent_encode_component(const char *s return result; } -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_userinfo_component(const char *str, const size_t str_length) +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_userinfo_percent_encode(const char *str, const size_t str_length) { return php_uri_parser_whatwg_percent_encode_component(str, str_length, LXB_URL_MAP_USERINFO, false); } -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_opaque_host_component(const char *str, const size_t str_length) +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_opaque_host_percent_encode(const char *str, const size_t str_length) { return php_uri_parser_whatwg_percent_encode_component(str, str_length, LXB_URL_MAP_C0, false); } -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_path_component(const char *str, const size_t str_length) +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_path_percent_encode(const char *str, const size_t str_length) { return php_uri_parser_whatwg_percent_encode_component(str, str_length, LXB_URL_MAP_PATH, false); } -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_opaque_path_component(const char *str, const size_t str_length) +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_opaque_path_percent_encode(const char *str, const size_t str_length) { return php_uri_parser_whatwg_percent_encode_component(str, str_length, LXB_URL_MAP_C0, false); } -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_path_segment_component(const char *str, const size_t str_length) +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_path_segment_percent_encode(const char *str, const size_t str_length) { ZEND_ASSERT((lexbor_custom_url_map['/'] & LXB_URL_MAP_PATH) == 0); @@ -708,22 +708,22 @@ ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_path_se return result; } -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_query_component(const char *str, const size_t str_length) +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_query_percent_encode(const char *str, const size_t str_length) { return php_uri_parser_whatwg_percent_encode_component(str, str_length, LXB_URL_MAP_QUERY, false); } -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_special_query_component(const char *str, const size_t str_length) +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_special_query_percent_encode(const char *str, const size_t str_length) { return php_uri_parser_whatwg_percent_encode_component(str, str_length, LXB_URL_MAP_SPECIAL_QUERY, false); } -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_form_query_component(const char *str, const size_t str_length) +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_form_query_percent_encode(const char *str, const size_t str_length) { return php_uri_parser_whatwg_percent_encode_component(str, str_length, LXB_URL_MAP_X_WWW_FORM, true); } -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_fragment_component(const char *str, const size_t str_length) +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_fragment_percent_encode(const char *str, const size_t str_length) { return php_uri_parser_whatwg_percent_encode_component(str, str_length, LXB_URL_MAP_FRAGMENT, false); } @@ -755,7 +755,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_always_inline zend_result php_uri_parser_what return FAILURE; } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_validate_none(const zend_string *component) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_none_validate(const zend_string *component) { return SUCCESS; } @@ -780,7 +780,7 @@ static zend_always_inline unsigned char php_uri_ascii_to_lowercase(const unsigne return c >= 'A' && c <= 'Z' ? (unsigned char) (c + ('a' - 'A')) : c; } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_validate_scheme(const zend_string *scheme) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_scheme_validate(const zend_string *scheme) { const char *p = ZSTR_VAL(scheme); const char *end = p + ZSTR_LEN(scheme); @@ -812,7 +812,7 @@ ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_validate_scheme(const z return SUCCESS; } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_validate_host(const zend_string *host) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_host_validate(const zend_string *host) { if (ZSTR_LEN(host) == 0) { /* Skip validation - an empty string may or may not be a valid host depending on whether the URL is special */ @@ -870,7 +870,7 @@ ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_validate_host(const zen return SUCCESS; } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_validate_port(const zend_long port) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_port_validate(const zend_long port) { if (port < 0) { return php_uri_parser_whatwg_component_error("port", LXB_URL_ERROR_TYPE_PORT_INVALID); diff --git a/ext/uri/uri_parser_whatwg.h b/ext/uri/uri_parser_whatwg.h index ee387a6af95d..ed19a1067a54 100644 --- a/ext/uri/uri_parser_whatwg.h +++ b/ext/uri/uri_parser_whatwg.h @@ -25,10 +25,10 @@ ZEND_ATTRIBUTE_NONNULL void php_uri_parser_whatwg_host_type_read(const lxb_url_t lxb_url_t *php_uri_parser_whatwg_parse_ex(const char *uri_str, size_t uri_str_len, const lxb_url_t *lexbor_base_url, zval *errors, bool silent); -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_validate_none(const zend_string *component); -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_validate_scheme(const zend_string *scheme); -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_validate_host(const zend_string *host); -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_validate_port(zend_long port); +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_none_validate(const zend_string *component); +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_scheme_validate(const zend_string *scheme); +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_host_validate(const zend_string *host); +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_whatwg_port_validate(zend_long port); ZEND_ATTRIBUTE_NONNULL_ARGS(2, 3, 4, 5, 6, 7, 8, 9) lxb_url_t *php_uri_parser_whatwg_build_from_zval( lxb_url_t *lexbor_base_url, const zval *scheme, const zval *username, const zval *password, @@ -36,15 +36,15 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(2, 3, 4, 5, 6, 7, 8, 9) lxb_url_t *php_uri_parser_wh zval *errors_zv ); -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_userinfo_component(const char *str, size_t str_length); -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_opaque_host_component(const char *str, size_t str_length); -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_path_component(const char *str, size_t str_length); -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_opaque_path_component(const char *str, size_t str_length); -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_path_segment_component(const char *str, size_t str_length); -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_query_component(const char *str, size_t str_length); -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_special_query_component(const char *str, size_t str_length); -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_form_query_component(const char *str, size_t str_length); -ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_percent_encode_fragment_component(const char *str, size_t str_length); +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_userinfo_percent_encode(const char *str, size_t str_length); +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_opaque_host_percent_encode(const char *str, size_t str_length); +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_path_percent_encode(const char *str, size_t str_length); +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_opaque_path_percent_encode(const char *str, size_t str_length); +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_path_segment_percent_encode(const char *str, size_t str_length); +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_query_percent_encode(const char *str, size_t str_length); +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_special_query_percent_encode(const char *str, size_t str_length); +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_form_query_percent_encode(const char *str, size_t str_length); +ZEND_ATTRIBUTE_NONNULL zend_string *php_uri_parser_whatwg_fragment_percent_encode(const char *str, size_t str_length); PHP_RINIT_FUNCTION(uri_parser_whatwg);