From 3b7071b4ca662d490aa70d3b44f84152d8fd2f65 Mon Sep 17 00:00:00 2001 From: "Eirik S. Morland" Date: Fri, 19 Aug 2016 15:57:55 +0200 Subject: [PATCH] Remove form feeds (Fix #141). --- lib/SparkPost/SparkPost.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/SparkPost/SparkPost.php b/lib/SparkPost/SparkPost.php index d4e9421..0d3c6b5 100644 --- a/lib/SparkPost/SparkPost.php +++ b/lib/SparkPost/SparkPost.php @@ -147,7 +147,13 @@ public function buildRequest($method, $uri, $payload, $headers) $url = $this->getUrl($uri, $params); $headers = $this->getHttpHeaders($headers); - return $this->getMessageFactory()->createRequest($method, $url, $headers, json_encode($body)); + // Sparkpost API will not tolerate form feed in JSON. + $jsonReplace = [ + '\f' => '', + ]; + $body = strtr(json_encode($body), $jsonReplace); + + return $this->getMessageFactory()->createRequest($method, $url, $headers, $body); } /**