Skip to content

Commit 46a6d48

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #72809: Locale::lookup() wrong result with canonicalize option
2 parents 8ae0658 + 13f3999 commit 46a6d48

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ext/intl/locale/locale_methods.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static zend_off_t getStrrtokenPos(char* str, zend_off_t savedPos)
146146
zend_off_t i;
147147

148148
for(i=savedPos-1; i>=0; i--) {
149-
if(isIDSeparator(*(str+i)) ){
149+
if(isIDSeparator(*(str+i)) || isKeywordSeparator(*(str+i))){
150150
/* delimiter found; check for singleton */
151151
if(i>=2 && isIDSeparator(*(str+i-2)) ){
152152
/* a singleton; so send the position of token before the singleton */

ext/intl/tests/locale/bug72809.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #72809 (Locale::lookup() wrong result with canonicalize option)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('intl')) die("skip intl extension not avaible");
6+
?>
7+
--FILE--
8+
<?php
9+
var_dump(
10+
Locale::lookup(['en', 'en-US'], 'en-US-u-cu-EUR-tz-deber-fw-mon', true),
11+
Locale::lookup(['en', 'en_US'], 'en_US@currency=eur;fw=mon;timezone=Europe/Berlin', false),
12+
Locale::lookup(['en', 'en_US'], 'en_US@currency=eur;fw=mon;timezone=Europe/Berlin', true),
13+
);
14+
?>
15+
--EXPECT--
16+
string(5) "en_us"
17+
string(5) "en_US"
18+
string(5) "en_us"

0 commit comments

Comments
 (0)