Bug #74168 [Opn->Fbk]: php://input is truncated
| From: | cmb@php.net | Date: | Sun, 26 Feb 2017 13:44:27 +0000 |
| Subject: | Bug #74168 [Opn->Fbk]: php://input is truncated | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207564@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74168&edit=1
ID: 74168
Updated by: cmb@php.net
Reported by: skaownz234 at gmail dot com
Summary: php://input is truncated
-Status: Open
+Status: Feedback
Type: Bug
Package: JSON related
Operating System: Centos 7 Minimal
PHP Version: 7.0.16
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> I'll send the JSON blob that causes the error via the patch file.
That does not work. Please provide the JSON somewhere else.
Also note that the input might be truncated due to post_max_size[1].
[1] <http://php.net/manual/en/ini.core.php#ini.post-max-size>
Previous Comments:
------------------------------------------------------------------------
[2017-02-25 23:46:17] skaownz234 at gmail dot com
Description:
------------
When sending JSON via php://input, my body was truncated at the point where it read
<<<<<. It seems that this signals php to stop reading in from php://input. The JSON
parse will fail since the truncation yields invalid JSON. I'll send the JSON blob that causes
the error via the patch file. I remove the pattern /(<|>)+/ as a work around at the moment.
Here's where it fails:
d63da06809da5cf7c712":false},"is_super_like":false,"is_boost_match":false,"person":{"_id":"56c1d63da06809da5cf7c712","badges":[],"bio":"Why
do guys put their height on here? Are we more compatible the taller we are? Let\'s test
it:\\n\\n4\'10\\"\\nLibra\\nSarcastic\\nENFJ\\nType A\\nAmbitious\\nSapiosexual
<<<<<<<<<<'
Pretty sure the <<<'s cause this. Seems like the underlying stream processor has some
sort of break condition dependent on the < symbols.
Test script:
---------------
POST something like {
<?php
$input = file_get_contents('php://input');
$j = json_decode(stripslashes(html_entity_decode($input)), true);
echo json_encode($j);
?>
Expected result:
----------------
All JSON data is received and retrievable via my $input variable for decoding.
Actual result:
--------------
JSON is truncated at an instance of '<<<<<<<<<<', rendering
it invalid.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74168&edit=1