com php-src: Fixed bug #73793 (WDDX uses wrong decimal seperator): NEWS ext/wddx/tests/bug73793.phpt ext/wddx/wddx.c
| From: | Christoph Michael Becker | Date: | Sun, 13 Aug 2017 18:51:53 +0000 |
| Subject: | com php-src: Fixed bug #73793 (WDDX uses wrong decimal seperator): NEWS ext/wddx/tests/bug73793.phpt ext/wddx/wddx.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98998@lists.php.net to get a copy of this message | ||
Commit: f64be0b0135f742df31bc97dd3c04f84f342878e
Author: Christoph M. Becker <cmbecker69@gmx.de> Sun, 13 Aug 2017 20:51:53 +0200
Parents: 472b25921e2d4c5c96423edac6d1225bb25ed874
Branches: PHP-7.0 PHP-7..1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f64be0b0135f742df31bc97dd3c04f84f342878e
Log:
Fixed bug #73793 (WDDX uses wrong decimal seperator)
The WDDX specification[1] requires to serialize floats with a decimal
point, but
snprintf() is locale-dependent and may use a decimal
comma. We fix that afterwards by replacing an eventual comma with a
point.
[1] <http://xml.coverpages.org/wddx0090-dtd-19980928.txt>
Bugs:
https://bugs.php.net/73793
Changed paths:
M NEWS
A ext/wddx/tests/bug73793.phpt
M ext/wddx/wddx.c
Diff:
diff --git a/NEWS b/NEWS
index 8920376..0723d99 100644
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,9 @@ PHP NEWS
. Fixed bug #75054 (A Denial of Service Vulnerability was found when
performing deserialization). (Nikita)
+- WDDX:
+ . Fixed bug #73793 (WDDX uses wrong decimal seperator). (cmb)
+
- XMLRPC:
. Fixed bug #74975 (Incorrect xmlrpc serialization for classes with declared
properties). (blar)
diff --git a/ext/wddx/tests/bug73793.phpt b/ext/wddx/tests/bug73793.phpt
new file mode 100644
index 0000000..fed4b35
--- /dev/null
+++ b/ext/wddx/tests/bug73793.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #73793 (WDDX uses wrong decimal seperator)
+--SKIPIF--
+<?php
+if (!extension_loaded('wddx')) print 'skip wddx extension not available';
+if (setlocale(LC_NUMERIC, ['de_DE', 'de_DE.UTF-8', 'de-DE']) ===
false) {
+ print 'skip German locale not available';
+}
+?>
+--FILE--
+<?php
+setlocale(LC_NUMERIC , ['de_DE', 'de_DE.UTF-8', 'de-DE']);
+var_dump(wddx_serialize_value(['foo' => 5.1]));
+?>
+===DONE===
+--EXPECT--
+string(120) "<wddxPacket
version='1.0'><header/><data><struct><var
name='foo'><number>5.1</number></var></struct></data></wddxPacket>"
+===DONE===
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index c1fe020..d67ee47 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -420,11 +420,15 @@ static void php_wddx_serialize_string(wddx_packet *packet, zval *var)
*/
static void php_wddx_serialize_number(wddx_packet *packet, zval *var)
{
- char tmp_buf[WDDX_BUF_LEN];
+ char tmp_buf[WDDX_BUF_LEN], *dec_point;
zend_string *str = zval_get_string(var);
snprintf(tmp_buf, sizeof(tmp_buf), WDDX_NUMBER, ZSTR_VAL(str));
zend_string_release(str);
+ dec_point = strchr(tmp_buf, ',');
+ if (dec_point) {
+ *dec_point = '..';
+ }
php_wddx_add_chunk(packet, tmp_buf);
}
/* }}} */