File tree Expand file tree Collapse file tree 1 file changed +24
-7
lines changed
src/Understand/UnderstandLaravel5/Handlers Expand file tree Collapse file tree 1 file changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -4,20 +4,18 @@ class AsyncHandler extends BaseHandler
44{
55
66 /**
7- * Send data to storage
8- *
9- * @param string $requestData
10- * @return void
7+ * @param string $escapedData
8+ * @return string|void
119 */
12- protected function send ($ requestData )
10+ protected function send ($ escapedData )
1311 {
1412 $ parts = [
1513 'curl ' ,
1614 '-X POST ' ,
1715 '--cacert ' ,
1816 $ this ->sslBundlePath ,
1917 '-d ' ,
20- escapeshellarg ( $ requestData ) ,
18+ $ escapedData ,
2119 $ this ->getEndpoint (),
2220 '> /dev/null 2>&1 & '
2321 ];
@@ -27,6 +25,21 @@ protected function send($requestData)
2725 exec ($ cmd );
2826 }
2927
28+ /**
29+ * @param $requestData
30+ * @return string|void
31+ */
32+ protected function escapeshellarg ($ requestData )
33+ {
34+ // the `escapeshellarg` function throws a fatal error in Unix if the size exceeds 2097152 bytes (~2mb)
35+ if (strlen ($ requestData ) >= 2000000 )
36+ {
37+ return ;
38+ }
39+
40+ return escapeshellarg ($ requestData );
41+ }
42+
3043 /**
3144 * Serialize data and send to storage
3245 *
@@ -36,7 +49,11 @@ protected function send($requestData)
3649 public function handle (array $ requestData )
3750 {
3851 $ json = json_encode ($ requestData );
52+ $ escapedData = $ this ->escapeshellarg ($ json );
3953
40- $ this ->send ($ json );
54+ if ($ escapedData )
55+ {
56+ return $ this ->send ($ escapedData );
57+ }
4158 }
4259}
You can’t perform that action at this time.
0 commit comments