#42186 [Bgs]: json_decode() won't work with \l

From: Date: Sat, 04 Aug 2007 14:42:17 +0000
Subject: #42186 [Bgs]: json_decode() won't work with \l
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115754@lists.php.net to get a copy of this message
ID: 42186 User updated by: djlopez at gmx dot de Reported By: djlopez at gmx dot de Status: Bogus Bug Type: JSON related Operating System: * PHP Version: 5.2.3 New Comment: I want to remember you, where JSON is used: Javascript - to send data to the server. When there's a textarea, some OS/Browser are sending an \l for a linebreak. So, if an \l is into the string, the _whole_ function won't work! Sometimes it also appears with an \n, but I can't reproduce this error. Maybe it has multiple causes. And as far as I can see, there's no thrown exception to catch this error. The function json_decode() may be implemented very strictly, but without an exception, it's very hard to debug the code. Please DON'T set this bug to closed!!! Don't ignore the not-that-good implementation! Thx! Previous Comments: ------------------------------------------------------------------------ [2007-08-04 14:24:00] jani@php.net And according to http://www.json.org/ \l is not in the accepted list of chars. So no bug here. ------------------------------------------------------------------------ [2007-08-04 14:17:56] jani@php.net Replace print_r() with var_dump() and you might actually see something. ------------------------------------------------------------------------ [2007-08-02 18:47:06] djlopez at gmx dot de Description: ------------ json_decode() returns nothing, when the string contains an \l (lowercase L), maybe (internal) crash!? Reproduce code: --------------- $json = '{"stringwithbreak":"line with a \lbreak!"}'; print_r(json_decode($json, true)); Expected result: ---------------- print_r() is NOT returning anything, json_decode() seems to be not executed. Actual result: -------------- Could be "solved" this way: print_r(json_decode(str_replace("\\l", "", $json), true)); However, it's a bug... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42186&edit=1

« previous php.bugs (#115754) next »