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
This commit is contained in:
Andrew O'Neil 2009-10-23 02:38:48 +00:00
parent c4e0d45742
commit 0a1392324a

View File

@ -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, "<?xml") === false) {
// If this template is a full HTML page, then put the comments just inside the HTML tag to prevent any IE glitches
if(stripos($content, "<html") !== false) {