php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40235 serialize breaks with floats if locale is set to de_DE
Submitted: 2007-01-25 12:34 UTC Modified: 2007-01-25 14:27 UTC
From: tacker@php.net Assigned:
Status: Closed Package: Variables related
PHP Version: 5.2.1RC3 OS: Gentoo Linux
Private report: No CVE-ID:
 [2007-01-25 12:34 UTC] tacker@php.net
Description:
------------
If locale is set to de_DE serialized arrays and objects with floats somewhere cannot be unserialized.

Reproduce code:
---------------
<?php

    error_reporting(E_ALL);
    ini_set('display_errors', 1);

    echo 'Setting locale to ' . setlocale(LC_ALL, 'de_DE') . "\n"; // Remove this to make it work

    $array = array('myval' => 1.2345);
    echo 'Serializing ';
    var_export($array);
    echo "\n";
    $serialized = serialize($array);
    echo 'Got: ' . $serialized . "\n";
    echo "Unserializing.\n";
    $unserialized = unserialize($serialized);
    echo 'Got: ' . var_export($unserialized, true) . "\n";
    echo 'This should be true: ' . var_export(($unserialized === $array), true) . "\n";

?>

Expected result:
----------------
$ php locale_serialize.php
Serializing array (
  'myval' => 1.2345,
)
Got: a:1:{s:5:"myval";d:1.2344999999999999307220832633902318775653839111328125;}
Unserializing.
Got: array (
  'myval' => 1.2345,
)
This should be true: true

Actual result:
--------------
$ php locale_serialize.php
Setting locale to de_DE
Serializing array (
  'myval' => 1,2345,
)
Got: a:1:{s:5:"myval";d:1,2344999999999999307220832633902318775653839111328125;}
Unserializing.

Notice: unserialize(): Error at offset 17 of 75 bytes in /var/www/alan-live/htdoc/test/locale_serialize.php on line 16
Got: false
This should be true: false

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-25 12:35 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2007-01-25 14:27 UTC] tacker@php.net
Fixed in PHP 5.2.1RC4-dev (cli) (built: Jan 25 2007 14:49:12)
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 16:02:23 2014 UTC