mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
ext/gettext: bind_textdomain_codeset should not accept empty domains.
the man page specifies that for bind_textdomain_codeset, like bindtextdomain, the domain should not be an empty string. close GH-13571
This commit is contained in:
4
NEWS
4
NEWS
@@ -47,6 +47,10 @@ PHP NEWS
|
||||
- FTP:
|
||||
. Removed the deprecated inet_ntoa call support. (David Carlier)
|
||||
|
||||
- Gettext:
|
||||
. bind_textdomain_codeset now throws an exception on empty domain.
|
||||
(David Carlier)
|
||||
|
||||
- IMAP:
|
||||
. Moved to PECL. (Derick Rethans)
|
||||
|
||||
|
||||
@@ -324,6 +324,9 @@ PHP 8.4 UPGRADE NOTES
|
||||
. DOMDocument::registerNodeClass() now has a tentative return type of true.
|
||||
Previously, the return type was bool but only true could be returned in practice.
|
||||
|
||||
- Gettext:
|
||||
. bind_textdomain_codeset now throws an exception if the domain's argument is empty.
|
||||
|
||||
- Intl:
|
||||
. IntlDateFormatter::__construct() throws a ValueError if the locale is invalid.
|
||||
. NumberFormatter::__construct() throws a ValueError if the locale is invalid.
|
||||
|
||||
@@ -171,7 +171,7 @@ PHP_FUNCTION(bindtextdomain)
|
||||
|
||||
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
|
||||
|
||||
if (domain[0] == '\0') {
|
||||
if (!domain_len) {
|
||||
zend_argument_value_error(1, "cannot be empty");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
@@ -283,6 +283,11 @@ PHP_FUNCTION(bind_textdomain_codeset)
|
||||
|
||||
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
|
||||
|
||||
if (!domain_len) {
|
||||
zend_argument_value_error(1, "cannot be empty");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
retval = bind_textdomain_codeset(domain, codeset);
|
||||
|
||||
if (!retval) {
|
||||
|
||||
@@ -4,13 +4,24 @@ test if bind_textdomain_codeset() returns correct value
|
||||
gettext
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(bind_textdomain_codeset(false,false));
|
||||
try {
|
||||
bind_textdomain_codeset(false,false);
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
bind_textdomain_codeset("", "UTF-8");
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
var_dump(bind_textdomain_codeset('messages', "UTF-8"));
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
bind_textdomain_codeset(): Argument #1 ($domain) cannot be empty
|
||||
bind_textdomain_codeset(): Argument #1 ($domain) cannot be empty
|
||||
string(5) "UTF-8"
|
||||
Done
|
||||
--CREDITS--
|
||||
|
||||
Reference in New Issue
Block a user