Bug #66496 [NEW]: conversion of UTF-8 strings containing language specific chars is wrong
From: care at novadys dot de
Operating system: Windows
PHP version: 5.5.8
Package: COM related
Bug Type: Bug
Bug description:conversion of UTF-8 strings containing language specific chars is wrong
Description:
------------
Using a UTF-8 String as input for a com-function will generate a wrong
string in COM interface. If the input string is containing n-chars which
are encoded with 2 bytes, the length of resulting string is n byte too
long.
example: "I want to Dusseldorf and Koln" is correctly handled
"I want to Düsseldorf and Köln" will call COM function with a string:
"I want to Düsseldorf and Köln\0\4"
reason:
ext/com_dotnet/com_variant.c
...
PHP_COM_DOTNET_API void php_com_variant_from_zval(VARIANT *v, zval *z,
int codepage TSRMLS_DC)
...
case IS_STRING:
V_VT(v) = VT_BSTR;
olestring =
php_com_string_to_olestring(Z_STRVAL_P(z), Z_STRLEN_P(z), codepage
TSRMLS_CC);
here is the problem:
V_BSTR(v) = SysAllocStringByteLen((char*)olestring, Z_STRLEN_P(z) *
sizeof(OLECHAR));
When input string is UTF-8 encoded Z_STRLEN_P(z) has a count of 2 byte
for each "special" char. So length of input string is count of all chars
+ count of "special" chars. After conversion to olestring Z_STRLEN_P(z)
is the wrong length the olestring is shorter. So SysAllocStringByteLen
is allocating too much memory and while the for the string length of
olestring. In result those strings are always showing a '\0' for the
first special char + n-1 random chars for the remaing special chars.
--
Edit bug report at https://bugs.php.net/bug.php?id=66496&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66496&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66496&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66496&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66496&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66496&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66496&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66496&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66496&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66496&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66496&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66496&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66496&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66496&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66496&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66496&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66496&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66496&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66496&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66496&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66496&r=mysqlcfg
Thread (5 messages)
- care at novadys dot de