Skip to content

Fix #72809: Locale::lookup() wrong result with canonicalize option #7151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/intl/locale/locale_methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static zend_off_t getStrrtokenPos(char* str, zend_off_t savedPos)
zend_off_t i;

for(i=savedPos-1; i>=0; i--) {
if(isIDSeparator(*(str+i)) ){
if(isIDSeparator(*(str+i)) || isKeywordSeparator(*(str+i))){
/* delimiter found; check for singleton */
if(i>=2 && isIDSeparator(*(str+i-2)) ){
/* a singleton; so send the position of token before the singleton */
Expand Down
18 changes: 18 additions & 0 deletions ext/intl/tests/locale/bug72809.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Bug #72809 (Locale::lookup() wrong result with canonicalize option)
--SKIPIF--
<?php
if (!extension_loaded('intl')) die("skip intl extension not avaible");
?>
--FILE--
<?php
var_dump(
Locale::lookup(['en', 'en-US'], 'en-US-u-cu-EUR-tz-deber-fw-mon', true),
Locale::lookup(['en', 'en_US'], 'en_US@currency=eur;fw=mon;timezone=Europe/Berlin', false),
Locale::lookup(['en', 'en_US'], 'en_US@currency=eur;fw=mon;timezone=Europe/Berlin', true),
);
?>
--EXPECT--
string(5) "en_us"
string(5) "en_US"
string(5) "en_us"