Permalink
Browse files

Don't die if a UTF encoding isn't supported.

Closes gh-199.
  • Loading branch information...
1 parent 1705c97 commit f1a7936a025c145363041dcb939aa6909e67432b @nex3 nex3 committed Nov 23, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/sass/util.rb
View
@@ -467,7 +467,8 @@ def check_sass_encoding(str, &block)
# We allow any printable ASCII characters but double quotes in the charset decl
bin = str.dup.force_encoding("BINARY")
encoding = Sass::Util::ENCODINGS_TO_CHECK.find do |enc|
- bin =~ Sass::Util::CHARSET_REGEXPS[enc]
+ re = Sass::Util::CHARSET_REGEXPS[enc]
+ re && bin =~ re
end
charset, bom = $1, $2
if charset
@@ -508,6 +509,8 @@ def _enc(string, encoding)
Regexp.new(/\A(?:#{_enc("\uFEFF", e)})?#{
_enc('@charset "', e)}(.*?)#{_enc('"', e)}|\A(#{
_enc("\uFEFF", e)})/)
+ rescue Encoding::ConverterNotFound => _
+ nil # JRuby on Java 5 doesn't support UTF-32
rescue
# /\A@charset "(.*?)"/
Regexp.new(/\A#{_enc('@charset "', e)}(.*?)#{_enc('"', e)}/)

0 comments on commit f1a7936

Please sign in to comment.