Skip to content

Commit

Permalink
Escape filenames that would generate illegal css comments. Closes Com…
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseppstein committed Jun 3, 2012
1 parent a05188b commit 0067855
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compass/sprite_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def self.sprite_names(uri)

# Returns the sass_options for this sprite
def self.sass_options(uri, importer, options)
options.merge!(:filename => uri, :syntax => :scss, :importer => importer)
options.merge!(:filename => uri.gsub(%r{\*/},"*\\/"), :syntax => :scss, :importer => importer)
end

# Returns a Sass::Engine for this sprite object
Expand Down
35 changes: 35 additions & 0 deletions test/units/regressions_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'test_helper'
require 'compass'
require 'compass/exec'
require 'stringio'

class RegressionsTest < Test::Unit::TestCase
include Compass::CommandLineHelper
setup do
Compass.reset_configuration!
end

after do
Compass.reset_configuration!
end

def test_issue911_sprites_with_globbing_and_line_comments
within_tmp_directory do
compass "create --bare issue911"
FileUtils.mkdir_p "issue911/images/sprites/a"
FileUtils.mkdir_p "issue911/images/sprites/b"
open "issue911/images/sprites/a/foo.png", "wb" do |f|
f.write(Compass::PNG.new(5,10, [255,0,255]).to_blob)
end
open "issue911/images/sprites/b/bar.png", "wb" do |f|
f.write(Compass::PNG.new(5,10, [255,255,0]).to_blob)
end
Dir.chdir "issue911" do
result = compile_for_project(<<-SCSS)
@import "sprites/**/*.png";
SCSS
Sass::Engine.new(result, :syntax => :scss).render # raises an error if we generated invalid css
end
end
end
end

0 comments on commit 0067855

Please sign in to comment.