Author: chabotc
Date: Tue Jun  3 06:43:21 2008
New Revision: 662798

URL: http://svn.apache.org/viewvc?rev=662798&view=rev
Log:
SHINDIG-326 : Uncaught exception for invalid request json

Modified:
    incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php

Modified: incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php?rev=662798&r1=662797&r2=662798&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php 
(original)
+++ incubator/shindig/trunk/php/src/socialdata/http/GadgetDataServlet.php Tue 
Jun  3 06:43:21 2008
@@ -67,20 +67,19 @@
 
        public function doPost()
        {
-               $requestParam = isset($_POST['request']) ? $_POST['request'] : 
'';
-               $token = isset($_POST['st']) ? $_POST['st'] : '';
-               // detect if magic quotes are on, and if so strip them from the 
request
-               if (get_magic_quotes_gpc()) {
-                       $requestParam = stripslashes($requestParam);
-               }
-               $request = json_decode($requestParam, true);
-               if ($request == $requestParam) {
-                       // oddly enough if the json_decode function can't parse 
the code,
-                       // it just returns the original string (instead of 
something usefull like 'null' or false :))
-                       throw new Exception("Invalid request JSON");
-               }
-               
                try {
+                       $requestParam = isset($_POST['request']) ? 
$_POST['request'] : '';
+                       $token = isset($_POST['st']) ? $_POST['st'] : '';
+                       // detect if magic quotes are on, and if so strip them 
from the request
+                       if (get_magic_quotes_gpc()) {
+                               $requestParam = stripslashes($requestParam);
+                       }
+                       $request = json_decode($requestParam, true);
+                       if ($request == $requestParam) {
+                               // oddly enough if the json_decode function 
can't parse the code,
+                               // it just returns the original string (instead 
of something usefull like 'null' or false :))
+                               throw new Exception("Invalid request JSON");
+                       }
                        $response = new 
DataResponse($this->createResponse($requestParam, $token));
                } catch (Exception $e) {
                        $response = new DataResponse(false, BAD_REQUEST);


Reply via email to