File tree 4 files changed +26
-3
lines changed
4 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ PHP NEWS
47
47
- FTP:
48
48
. Removed the deprecated inet_ntoa call support. (David Carlier)
49
49
50
+ - Gettext:
51
+ . bind_textdomain_codeset now throws an exception on empty domain.
52
+ (David Carlier)
53
+
50
54
- IMAP:
51
55
. Moved to PECL. (Derick Rethans)
52
56
Original file line number Diff line number Diff line change @@ -324,6 +324,9 @@ PHP 8.4 UPGRADE NOTES
324
324
. DOMDocument::registerNodeClass() now has a tentative return type of true.
325
325
Previously, the return type was bool but only true could be returned in practice.
326
326
327
+ - Gettext:
328
+ . bind_textdomain_codeset now throws an exception if the domain's argument is empty.
329
+
327
330
- Intl:
328
331
. IntlDateFormatter::__construct() throws a ValueError if the locale is invalid.
329
332
. 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)
171
171
172
172
PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
173
173
174
- if (domain [ 0 ] == '\0' ) {
174
+ if (! domain_len ) {
175
175
zend_argument_value_error (1 , "cannot be empty" );
176
176
RETURN_THROWS ();
177
177
}
@@ -283,6 +283,11 @@ PHP_FUNCTION(bind_textdomain_codeset)
283
283
284
284
PHP_GETTEXT_DOMAIN_LENGTH_CHECK (1 , domain_len )
285
285
286
+ if (!domain_len ) {
287
+ zend_argument_value_error (1 , "cannot be empty" );
288
+ RETURN_THROWS ();
289
+ }
290
+
286
291
retval = bind_textdomain_codeset (domain , codeset );
287
292
288
293
if (!retval ) {
Original file line number Diff line number Diff line change @@ -4,13 +4,24 @@ test if bind_textdomain_codeset() returns correct value
4
4
gettext
5
5
--FILE--
6
6
<?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
+ }
8
18
var_dump (bind_textdomain_codeset ('messages ' , "UTF-8 " ));
9
19
10
20
echo "Done \n" ;
11
21
?>
12
22
--EXPECT--
13
- bool(false)
23
+ bind_textdomain_codeset(): Argument #1 ($domain) cannot be empty
24
+ bind_textdomain_codeset(): Argument #1 ($domain) cannot be empty
14
25
string(5) "UTF-8"
15
26
Done
16
27
--CREDITS--
You can’t perform that action at this time.
0 commit comments