From 0a1392324a04e5dcb4d331c8827b7b4b2c5fcc78 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Fri, 23 Oct 2009 02:38:48 +0000 Subject: [PATCH] BUGFIX: UTF-8 byte order mark gets propagated from template files (#4357) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@90056 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/SSViewer.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/core/SSViewer.php b/core/SSViewer.php index 666a4c9a6..dd8e791d2 100755 --- a/core/SSViewer.php +++ b/core/SSViewer.php @@ -276,7 +276,15 @@ class SSViewer { return null; } - return file_get_contents(SSViewer::getTemplateFile($identifier)); + $content = file_get_contents(SSViewer::getTemplateFile($identifier)); + + // Remove UTF-8 byte order mark + // This is only necessary if you don't have zend-multibyte enabled. + if(substr($content, 0,3) == pack("CCC", 0xef, 0xbb, 0xbf)) { + $content = substr($content, 3); + } + + return $content; } /** @@ -374,8 +382,13 @@ class SSViewer { } static function parseTemplateContent($content, $template="") { - // Add template filename comments on dev sites + // Remove UTF-8 byte order mark: + // This is only necessary if you don't have zend-multibyte enabled. + if(substr($content, 0,3) == pack("CCC", 0xef, 0xbb, 0xbf)) { + $content = substr($content, 3); + } + // Add template filename comments on dev sites if(Director::isDev() && self::$source_file_comments && $template && stripos($content, "