diff --git a/README b/README index 35a481c..bde1ae0 100644 --- a/README +++ b/README @@ -65,3 +65,9 @@ MINIFY USAGE Example 1 shows an example of using Minify to serve external CSS and JS files with far-off Expires headers. Clients will always have up-to-date versions because Minify_Build is used to time stamp the URLs. + +FILE ENCODINGS + +Minify *should* work fine with files encoded in UTF-8 or other 8-bit +encodings like ISO 8859/Windows-1252. Leading UTF-8 BOMs are stripped from +all sources to prevent duplication in output files. diff --git a/lib/Minify/Source.php b/lib/Minify/Source.php index 32af571..337931e 100644 --- a/lib/Minify/Source.php +++ b/lib/Minify/Source.php @@ -78,12 +78,16 @@ class Minify_Source { */ public function getContent() { - return (null !== $this->_filepath) + $content = (null !== $this->_filepath) ? file_get_contents($this->_filepath) : ((null !== $this->_content) ? $this->_content : call_user_func($this->_getContentFunc, $this->_id) ); + // remove UTF-8 BOM if present + return (pack("CCC",0xef,0xbb,0xbf) === substr($content, 0, 3)) + ? substr($content, 3) + : $content; } /** diff --git a/web/test/_test_files/minify/QueryString.js b/web/test/_test_files/minify/QueryString.js index d926d64..e56a244 100644 --- a/web/test/_test_files/minify/QueryString.js +++ b/web/test/_test_files/minify/QueryString.js @@ -1,4 +1,4 @@ -var MrClay = window.MrClay || {}; +var MrClay = window.MrClay || {}; /** * Simplified access to/manipulation of the query string diff --git a/web/test/_test_files/minify/email.js b/web/test/_test_files/minify/email.js index b725379..761062d 100644 --- a/web/test/_test_files/minify/email.js +++ b/web/test/_test_files/minify/email.js @@ -1,4 +1,4 @@ -// http://mrclay.org/ +// http://mrclay.org/ (function(){ var reMailto = /^mailto:my_name_is_(\S+)_and_the_domain_is_(\S+)$/,