File tree Expand file tree Collapse file tree 4 files changed +26
-3
lines changed
Expand file tree Collapse file tree 4 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ PHP NEWS
4747- FTP:
4848 . Removed the deprecated inet_ntoa call support. (David Carlier)
4949
50+ - Gettext:
51+ . bind_textdomain_codeset now throws an exception on empty domain.
52+ (David Carlier)
53+
5054- IMAP:
5155 . Moved to PECL. (Derick Rethans)
5256
Original file line number Diff line number Diff line change @@ -324,6 +324,9 @@ PHP 8.4 UPGRADE NOTES
324324 . DOMDocument::registerNodeClass() now has a tentative return type of true.
325325 Previously, the return type was bool but only true could be returned in practice.
326326
327+ - Gettext:
328+ . bind_textdomain_codeset now throws an exception if the domain's argument is empty.
329+
327330- Intl:
328331 . IntlDateFormatter::__construct() throws a ValueError if the locale is invalid.
329332 . NumberFormatter::__construct() throws a ValueError if the locale is invalid.
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ PHP_FUNCTION(bindtextdomain)
171171
172172 PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
173173
174- if (domain [ 0 ] == '\0' ) {
174+ if (! domain_len ) {
175175 zend_argument_value_error (1 , "cannot be empty" );
176176 RETURN_THROWS ();
177177 }
@@ -283,6 +283,11 @@ PHP_FUNCTION(bind_textdomain_codeset)
283283
284284 PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
285285
286+ if (!domain_len ) {
287+ zend_argument_value_error (1 , "cannot be empty" );
288+ RETURN_THROWS ();
289+ }
290+
286291 retval = bind_textdomain_codeset (domain , codeset );
287292
288293 if (!retval ) {
Original file line number Diff line number Diff line change @@ -4,13 +4,24 @@ test if bind_textdomain_codeset() returns correct value
44gettext
55--FILE--
66<?php
7- var_dump (bind_textdomain_codeset (false ,false ));
7+ try {
8+ bind_textdomain_codeset (false ,false );
9+ } catch (ValueError $ e ) {
10+ echo $ e ->getMessage () . PHP_EOL ;
11+ }
12+
13+ try {
14+ bind_textdomain_codeset ("" , "UTF-8 " );
15+ } catch (ValueError $ e ) {
16+ echo $ e ->getMessage () . PHP_EOL ;
17+ }
818 var_dump (bind_textdomain_codeset ('messages ' , "UTF-8 " ));
919
1020 echo "Done \n" ;
1121?>
1222--EXPECT--
13- bool(false)
23+ bind_textdomain_codeset(): Argument #1 ($domain) cannot be empty
24+ bind_textdomain_codeset(): Argument #1 ($domain) cannot be empty
1425string(5) "UTF-8"
1526Done
1627--CREDITS--
You can’t perform that action at this time.
0 commit comments