]> granicus.if.org Git - php/commitdiff
Made unserialize handle floats with an E notation - bug #18654
authorSander Roobol <sander@php.net>
Mon, 19 Aug 2002 19:45:46 +0000 (19:45 +0000)
committerSander Roobol <sander@php.net>
Mon, 19 Aug 2002 19:45:46 +0000 (19:45 +0000)
Patch by Christophe Sollet <csollet@coleebris.com>.
(I'll commit a new var_unserializer.c in a second)

ext/standard/tests/serialize/003.phpt [new file with mode: 0644]
ext/standard/var_unserializer.re

diff --git a/ext/standard/tests/serialize/003.phpt b/ext/standard/tests/serialize/003.phpt
new file mode 100644 (file)
index 0000000..43e9077
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+unserialize() floats with E notation (#18654)
+--POST--
+--GET--
+--FILE--
+<?php 
+foreach(array(1e2, 5.2e25, 85.29e-23, 9e-9) AS $value) {
+       echo ($ser = serialize($value))."\n";
+       var_dump(unserialize($ser));
+       echo "\n";
+}
+?>
+--EXPECT--
+d:100;
+float(100)
+
+d:5.2E+25;
+float(5.2E+25)
+
+d:8.529E-22;
+float(8.529E-22)
+
+d:9E-09;
+float(9.E-9)
index 185909492b70ef1e9c26dfc13e6c425568414029..1e6dcd078c572e2e85877430a1e9686ee08e930c 100644 (file)
@@ -92,7 +92,7 @@ PHPAPI void var_destroy(php_unserialize_data_t *var_hashx)
 /*!re2c
 iv = [+-]? [0-9]+;
 nv = [+-]? ([0-9]* "." [0-9]+|[0-9]+ "." [0-9]+);
-nvexp = nv [eE] [+-]? iv;
+nvexp = (iv | nv) [eE] [+-]? iv;
 any = [\000-\277];
 */