From 0f9a4451195ac911d2daaf439fa5d50a13ce11a6 Mon Sep 17 00:00:00 2001 From: "Kevin J. Lynagh" Date: Tue, 17 Jan 2012 18:23:17 -0800 Subject: [PATCH] Concatenate JavaScript files with ";\n" rather than just "\n" to prevent unintentional function calls. --- lib/jammit/compressor.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/jammit/compressor.rb b/lib/jammit/compressor.rb index b2d1e752..542982e6 100644 --- a/lib/jammit/compressor.rb +++ b/lib/jammit/compressor.rb @@ -67,9 +67,9 @@ def initialize # YUI Compressor (with munging enabled). JST can optionally be included. def compress_js(paths) if (jst_paths = paths.grep(Jammit.template_extension_matcher)).empty? - js = concatenate(paths) + js = concatenate(paths, ";\n") else - js = concatenate(paths - jst_paths) + compile_jst(jst_paths) + js = concatenate(paths - jst_paths, ";\n") + compile_jst(jst_paths) end Jammit.compress_assets ? @js_compressor.compress(js) : js end @@ -240,8 +240,8 @@ def mime_type(asset_path) end # Concatenate together a list of asset files. - def concatenate(paths) - [paths].flatten.map {|p| read_binary_file(p) }.join("\n") + def concatenate(paths, separator="\n") + [paths].flatten.map {|p| read_binary_file(p) }.join(separator) end # `File.read`, but in "binary" mode.