[php-src] master: ext/mbstring: Always pass length to php_mb_get_encoding_or_pass()

From: Date: Wed, 24 Apr 2024 14:39:56 +0000
Subject: [php-src] master: ext/mbstring: Always pass length to php_mb_get_encoding_or_pass()
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-128231@lists.php.net to get a copy of this message
Author: Gina Peter Banyard (Girgias) Date: 2024-04-24T15:39:47+01:00 Commit: https://github.com/php/php-src/commit/86dfbadc0647b9640781e8a6165a6a7f730d640e Raw diff: https://github.com/php/php-src/commit/86dfbadc0647b9640781e8a6165a6a7f730d640e.diff ext/mbstring: Always pass length to php_mb_get_encoding_or_pass() We have access to this information, so propagate it instead of calling strlen(). This also removes the newly introduced _ex() variant. Changed paths: M ext/mbstring/mbstring.c Diff: diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 7beccca3c5f9..dc1f81f49c50 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -269,12 +269,12 @@ static const mbfl_encoding *php_mb_get_encoding(zend_string *encoding_name, uint } } -static const mbfl_encoding *php_mb_get_encoding_or_pass(const char *encoding_name) { - if (strcmp(encoding_name, "pass") == 0) { +static const mbfl_encoding *php_mb_get_encoding_or_pass(const char *encoding_name, size_t encoding_name_len) { + if (strncmp(encoding_name, "pass", encoding_name_len) == 0) { return &mbfl_encoding_pass; } - return mbfl_name2encoding(encoding_name); + return mbfl_name2encoding_ex(encoding_name, encoding_name_len); } static size_t count_commas(const char *p, const char *end) { @@ -761,7 +761,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_input) /* }}} */ static zend_result _php_mb_ini_mbstring_http_output_set(const char *new_value, size_t length) { - const mbfl_encoding *encoding = php_mb_get_encoding_or_pass(new_value); + const mbfl_encoding *encoding = php_mb_get_encoding_or_pass(new_value, length); if (!encoding) { return FAILURE; } @@ -1348,7 +1348,7 @@ PHP_FUNCTION(mb_http_output) ZEND_ASSERT(MBSTRG(current_http_output_encoding)); RETURN_STRING(MBSTRG(current_http_output_encoding)->name); } else { - const mbfl_encoding *encoding = php_mb_get_encoding_or_pass(name); + const mbfl_encoding *encoding = php_mb_get_encoding_or_pass(name, name_len); if (!encoding) { zend_argument_value_error(1, "must be a valid encoding, \"%s\" given", name); RETURN_THROWS();

« previous php.cvs (#128231) next »