note 82384 deleted from function.json-decode by danbrown

From: Date: Sat, 02 May 2009 14:55:25 +0000
Subject: note 82384 deleted from function.json-decode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154140@lists.php.net to get a copy of this message
Note Submitter: Hayley Watson ---- @AMA3: "It's strange that forward-slash is permitted to be escaped but not required to be, and that it has the same meaning either way, but that's how it's written, and so shall it be." JavaScript ignores '\' characters that don't start any sort of escape sequence, so as far as it is concerned, "\/" is equivalent to "/" (ECMA-262, §7.8.4). So in that sense it's permitted but not required to be: so why do it? json_encode("</script>") will produce "<\/script>" so that HTML parsers don't see a </script> end tag and choke on it (to play it safe and simplify the implementation, it escapes all '/'s); json_decode() therefore has to cope with that. As for it being necessary, I agree: it isn't on MY machine :) json_decode('{"a":"<p>test<\/p>"}'); ==> (object)array('a' => '<p>test</p>'); json_decode('{"a":"<p>test</p>"}'); ==> (object)array('a' => '<p>test</p>');

« previous php.notes (#154140) next »