From 9b479958f613e2ce1d290f26d246e76313e821f2 Mon Sep 17 00:00:00 2001 From: frederikweber Date: Sun, 18 Nov 2012 12:25:45 +0100 Subject: [PATCH] Send charset=UTF-8 if Content-Type is JSON. --- lib/Cake/Network/CakeResponse.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index e3cb8a921c0..67b9c90da1c 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -409,8 +409,10 @@ protected function _setContentType() { if (in_array($this->_status, array(304, 204))) { return; } - if (strpos($this->_contentType, 'text/') === 0 || $this->_contentType === 'application/json') { + if (strpos($this->_contentType, 'text/') === 0) { $this->header('Content-Type', "{$this->_contentType}; charset={$this->_charset}"); + } else if ($this->_contentType === 'application/json') { + $this->header('Content-Type', "{$this->_contentType}; charset=UTF-8"); } else { $this->header('Content-Type', "{$this->_contentType}"); }