CRM-13139 - CRM_Utils_REST - Accept empty JSON objects ("{}")
authorTim Otten <totten@civicrm.org>
Wed, 31 Jul 2013 23:59:32 +0000 (16:59 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 31 Jul 2013 23:59:32 +0000 (16:59 -0700)
Note: When the "json" parameter includes malformed JSON (eg "{") or an empty
string (""), the behavior is unchanged. This only affects a well-formed empty-obect.

----------------------------------------
* CRM-13139: REST API: json_decode() fails for empty input
  http://issues.civicrm.org/jira/browse/CRM-13139

CRM/Utils/REST.php

index 6a6971aa10f26030861d41c039871b6d3950db88..4403a39e1e5f916b2e8e884acb44b12d74762763 100644 (file)
@@ -378,7 +378,7 @@ class CRM_Utils_REST {
 
     if (array_key_exists('json', $_REQUEST) &&  $_REQUEST['json'][0] == "{") {
       $params = json_decode($_REQUEST['json'], TRUE);
-      if(empty($params)) {
+      if($params === NULL) {
         echo json_encode(array('is_error' => 1, 'error_message', 'Unable to decode supplied JSON.'));
         CRM_Utils_System::civiExit();
       }