mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
ext/intl: Fix Uconverter::transcode with substitutes as references.
close GH-18059
This commit is contained in:
parent
f34859cb90
commit
005c7b5797
3 changed files with 25 additions and 2 deletions
1
NEWS
1
NEWS
|
@ -20,6 +20,7 @@ PHP NEWS
|
||||||
with values as references. (David Carlier)
|
with values as references. (David Carlier)
|
||||||
. Fix dateformat_format when the time is an array of references.
|
. Fix dateformat_format when the time is an array of references.
|
||||||
(David Carlier)
|
(David Carlier)
|
||||||
|
. Fix UConverter::transcode with substitutes as references. (David Carlier)
|
||||||
|
|
||||||
- Embed:
|
- Embed:
|
||||||
. Fixed bug GH-8533 (Unable to link dynamic libphp on Mac). (Kévin Dunglas)
|
. Fixed bug GH-8533 (Unable to link dynamic libphp on Mac). (Kévin Dunglas)
|
||||||
|
|
|
@ -749,13 +749,13 @@ PHP_METHOD(UConverter, transcode) {
|
||||||
zval *tmpzval;
|
zval *tmpzval;
|
||||||
|
|
||||||
if (U_SUCCESS(error) &&
|
if (U_SUCCESS(error) &&
|
||||||
(tmpzval = zend_hash_str_find(Z_ARRVAL_P(options), "from_subst", sizeof("from_subst") - 1)) != NULL &&
|
(tmpzval = zend_hash_str_find_deref(Z_ARRVAL_P(options), "from_subst", sizeof("from_subst") - 1)) != NULL &&
|
||||||
Z_TYPE_P(tmpzval) == IS_STRING) {
|
Z_TYPE_P(tmpzval) == IS_STRING) {
|
||||||
error = U_ZERO_ERROR;
|
error = U_ZERO_ERROR;
|
||||||
ucnv_setSubstChars(src_cnv, Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval) & 0x7F, &error);
|
ucnv_setSubstChars(src_cnv, Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval) & 0x7F, &error);
|
||||||
}
|
}
|
||||||
if (U_SUCCESS(error) &&
|
if (U_SUCCESS(error) &&
|
||||||
(tmpzval = zend_hash_str_find(Z_ARRVAL_P(options), "to_subst", sizeof("to_subst") - 1)) != NULL &&
|
(tmpzval = zend_hash_str_find_deref(Z_ARRVAL_P(options), "to_subst", sizeof("to_subst") - 1)) != NULL &&
|
||||||
Z_TYPE_P(tmpzval) == IS_STRING) {
|
Z_TYPE_P(tmpzval) == IS_STRING) {
|
||||||
error = U_ZERO_ERROR;
|
error = U_ZERO_ERROR;
|
||||||
ucnv_setSubstChars(dest_cnv, Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval) & 0x7F, &error);
|
ucnv_setSubstChars(dest_cnv, Z_STRVAL_P(tmpzval), Z_STRLEN_P(tmpzval) & 0x7F, &error);
|
||||||
|
|
22
ext/intl/tests/uconverter_transcode_references.phpt
Normal file
22
ext/intl/tests/uconverter_transcode_references.phpt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
--TEST--
|
||||||
|
UConverter::transcode issue with substitutes values as references
|
||||||
|
--EXTENSIONS--
|
||||||
|
intl
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$subst = '??';
|
||||||
|
$opts = array('from_subst' => '?', 'to_subst' => &$subst);
|
||||||
|
var_dump(UConverter::transcode("This is an ascii string", 'ascii', 'utf-8', $opts));
|
||||||
|
$opts = array('from_subst' => &$subst, 'to_subst' => '?');
|
||||||
|
var_dump(UConverter::transcode("This is an ascii string", 'ascii', 'utf-8', $opts));
|
||||||
|
// should yield the same results
|
||||||
|
$opts = array('from_subst' => '?', 'to_subst' => '??');
|
||||||
|
var_dump(UConverter::transcode("This is an ascii string", 'ascii', 'utf-8', $opts));
|
||||||
|
$opts = array('from_subst' => '??', 'to_subst' => '?');
|
||||||
|
var_dump(UConverter::transcode("This is an ascii string", 'ascii', 'utf-8', $opts));
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
bool(false)
|
||||||
|
string(23) "This is an ascii string"
|
||||||
|
bool(false)
|
||||||
|
string(23) "This is an ascii string"
|
Loading…
Add table
Add a link
Reference in a new issue