Skip to content

Commit

Permalink
Fix not recognizing POST arguments if Content-Type is wrongly set to …
Browse files Browse the repository at this point in the history
…application/json
  • Loading branch information
kijin committed May 16, 2016
1 parent 03d2ab3 commit f8b76b5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions classes/context/Context.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ private function __construct()
public function init()
{
// Fix missing HTTP_RAW_POST_DATA in PHP 5.6 and above.
if(!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE)
if(!isset($GLOBALS['HTTP_RAW_POST_DATA']) && !count($_FILES) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE)
{
$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");

// If content is not XML or JSON, unset
if(!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']))
if(!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === false && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === false)
{
unset($GLOBALS['HTTP_RAW_POST_DATA']);
}
Expand Down

0 comments on commit f8b76b5

Please sign in to comment.