[BUGFIX] Automatically remove BOM from files before concatenation 36/45936/2
authorChristian Futterlieb <christian@futterlieb.ch>
Tue, 12 Jan 2016 14:32:30 +0000 (15:32 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Fri, 15 Jan 2016 12:47:19 +0000 (13:47 +0100)
Resolves: #72648
Releases: master, 7.6
Change-Id: I12d97a4bda70879c039d8b05390cc5e37fbeef51
Reviewed-on: https://review.typo3.org/45936
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/core/Classes/Resource/ResourceCompressor.php

index b3f12cf..4a6e4ad 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Resource;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Compressor
@@ -365,6 +366,10 @@ class ResourceCompressor
             // concatenate all the files together
             foreach ($filesToInclude as $filename) {
                 $contents = GeneralUtility::getUrl(GeneralUtility::resolveBackPath($this->rootPath . $filename));
+                // remove any UTF-8 byte order mark (BOM) from files
+                if (StringUtility::beginsWith($contents, "\xEF\xBB\xBF")) {
+                    $contents = substr($contents, 3);
+                }
                 // only fix paths if files aren't already in typo3temp (already processed)
                 if ($type === 'css' && !GeneralUtility::isFirstPartOfStr($filename, $this->targetDirectory)) {
                     $contents = $this->cssFixRelativeUrlPaths($contents, PathUtility::dirname($filename) . '/');