{"issue":{"created_at":"2011-11-21T23:11:36Z","state":"open","updated_at":"2011-11-21T23:18:35Z","user":{"gravatar_id":"80791db51f2441d434876d4870b443cf","id":649758,"url":"https://api.github.com/users/pedigree","login":"pedigree","avatar_url":"https://secure.gravatar.com/avatar/80791db51f2441d434876d4870b443cf?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":2,"body":"This showed due to random issues with a redis client, which works perfectly in PHP itself\r\n\r\nUsing function and vars \r\n\r\ndefine('CRLF', sprintf('%s%s', chr(13), chr(10)));\r\nfunction bintohex($str) {\r\n    $hex = \"\"; $i = 0; do {\r\n        $hex .= sprintf(\"%02x\", ord($str{$i})); $i++;\r\n    } while ($i < strlen($str));\r\n    return $hex;\r\n}\r\n$args[0] = \"\\x00\\x5f\";\r\n$args[1] = \"\\x81\\x77\\x97\\xa1\\x8d\\x4a\\x25\\xc1\\x83\\x71\\xa0\\x50\\x02\\xb7\";\r\n$name = 'hset';\r\n\r\nthis is the code that produces different output in HipHop and PHP\r\n\r\narray_unshift($args, strtoupper($name));\r\n$command = sprintf('*%d%s%s%s', count($args), CRLF, implode(array_map(function($arg) {\r\n     return sprintf('$%d%s%s', strlen($arg), CRLF, $arg);\r\n}, $args), CRLF), CRLF);\r\nprint \"command = \" . bintohex($command); \r\n\r\nIn PHP you get the correct output of \r\n\r\n2a330d0a24340d0a484745540d0a24320d0a005f0d0a2431340d0a817797a18d4a25c18371a05002b70d0a\r\n\r\nIn HipHop, you get an incorrect hexdump as it has missed the binary \\x00\\x5F $args[0] in the pass back and passes back an empty string so that you end up with 0d0a0d0a instead of 0d0a005f0d0a\r\n\r\n2a330d0a24340d0a484745540d0a24320d0a0d0a2431340d0a817797a18d4a25c18371a05002b70d0a\r\n","assignee":null,"id":2310872,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":432,"labels":[],"title":"array_map as function parsing failure with binary packed strings.","closed_at":null,"html_url":"https://github.com/facebook/hiphop-php/issues/432","url":"https://api.github.com/repos/facebook/hiphop-php/issues/432","milestone":null},"action":"created","comment":{"created_at":"2011-11-21T23:18:35Z","updated_at":"2011-11-21T23:18:35Z","user":{"gravatar_id":"80791db51f2441d434876d4870b443cf","id":649758,"url":"https://api.github.com/users/pedigree","login":"pedigree","avatar_url":"https://secure.gravatar.com/avatar/80791db51f2441d434876d4870b443cf?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"I think it basically faults sprintf on a \\x00 as the start of a string","id":2823012,"url":"https://api.github.com/repos/facebook/hiphop-php/issues/comments/2823012"}}