Move charset declaration to content-type header
Move charset declaration to content-type header

--- a/include/controller/ControllerBase.class.php
+++ b/include/controller/ControllerBase.class.php
@@ -449,6 +449,7 @@
 	 */
 	protected function LoadHeaders()
 	{
+		$this->headers[] = 'Content-Type: text/html; charset=UTF-8';
 	}
 
 	/**
@@ -551,7 +552,16 @@
 		$this->LoadHeaders();
 
 		if (count($this->headers) > 0) {
+			$hascontenttype = false;
 			foreach ($this->headers as $hdr) {
+				if (empty($hdr))
+					continue;
+
+				if (strncmp($hdr, 'Content-Type:', 13) === 0) {
+					if ($hascontenttype)
+						throw new Exception('Duplicate Content-Type header');
+					$hascontenttype = true;
+				}
 				header($hdr);
 			}
 		}

--- a/include/controller/Controller_Blob.class.php
+++ b/include/controller/Controller_Blob.class.php
@@ -103,6 +103,8 @@
 			$out = $this->tpl->fetch('blobheaders.tpl', $this->GetFullCacheKey());
 
 			$this->headers = unserialize(trim($out));
+		} else {
+			parent::LoadHeaders();
 		}
 
 	}

--- a/include/controller/Controller_DiffBase.class.php
+++ b/include/controller/Controller_DiffBase.class.php
@@ -100,6 +100,8 @@
 		if ($this->Plain()) {
 			$this->DisableLogging();
 			$this->headers[] = 'Content-type: text/plain; charset=UTF-8';
+		} else {
+			parent::LoadHeaders();
 		}
 	}
 

--- a/include/controller/Controller_Message.class.php
+++ b/include/controller/Controller_Message.class.php
@@ -83,6 +83,8 @@
 	 */
 	protected function LoadHeaders()
 	{
+		parent::LoadHeaders();
+
 		if (($this->params['exception'] instanceof GitPHP_MessageException) && ($this->params['exception']->StatusCode)) {
 			$partialHeader = $this->StatusCodeHeader($this->params['exception']->StatusCode);
 			if (!empty($partialHeader)) {

--- a/include/controller/Controller_ProjectList.class.php
+++ b/include/controller/Controller_ProjectList.class.php
@@ -91,6 +91,8 @@
 			$this->headers[] = "Content-type: text/plain; charset=utf-8";
 			$this->headers[] = "Content-Disposition: inline; filename=\"index.aux\"";
 			$this->DisableLogging();
+		} else {
+			parent::LoadHeaders();
 		}
 	}
 

--- a/templates/main.tpl
+++ b/templates/main.tpl
@@ -17,7 +17,6 @@
     {$pagetitle}
     {/block}
     </title>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     {block name=feeds}
     {/block}
     {block name=links}

comments