Permalink
Browse files

Clean up file paths when importing.

Closes #1076
  • Loading branch information...
nex3 committed Jan 23, 2014
1 parent a81052e commit 53263e373d520f240ad2bd4e83d7ef92e98cee24
@@ -411,6 +411,9 @@ of all directives, but will preserve any CSS rules.
* Don't crash when parsing a directive with no name in the indented syntax.
+* Clean up file paths when importing to avoid errors for overlong path
+ names.
+
## 3.2.13
* Numbers returned by user-defined functions now trigger division, just like
@@ -133,7 +133,7 @@ def find_real_file(dir, name, options)
path = dir == "." || Pathname.new(f).absolute? ? f : "#{escape_glob_characters(dir)}/#{f}"
Dir[path].map do |full_path|
full_path.gsub!(REDUNDANT_DIRECTORY, File::SEPARATOR)
- [full_path, s]
+ [Pathname.new(full_path).cleanpath.to_s, s]
end
end
found = Sass::Util.flatten(found, 1)
@@ -192,10 +192,6 @@ def _find(dir, name, options)
options[:importer] = self
Sass::Engine.new(File.read(full_filename), options)
end
-
- def join(base, path)
- Pathname.new(base).join(path).to_s
- end
end
end
end
View
@@ -164,6 +164,20 @@ def test_double_level_import_loop
end
end
+ def test_import_name_cleanup
+ File.delete(tempfile_loc('subdir/import_up1'))
+ check_for_updates!
+ File.open(tempfile_loc('subdir/import_up1')) do |file|
+ assert_equal(<<CSS.strip, file.read.split("\n")[0...5].join("\n"))
+/*
+Syntax error: File to import not found or unreadable: ../subdir/import_up3.scss.
+ Load path: #{template_loc}
+ on line 1 of #{template_loc 'subdir/import_up2'}
+ from line 1 of #{template_loc 'subdir/import_up1'}
+CSS
+ end
+ end
+
def test_nonfull_exception_handling
old_full_exception = Sass::Plugin.options[:full_exception]
Sass::Plugin.options[:full_exception] = false
@@ -0,0 +1 @@
+@import "../subdir/import_up2.scss";
@@ -0,0 +1 @@
+@import "../subdir/import_up3.scss";

0 comments on commit 53263e3

Please sign in to comment.