mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Support Unicode-escapes in Sass strings.
This commit is contained in:
parent
64b777d6d6
commit
9ebbe62230
2 changed files with 11 additions and 1 deletions
|
@ -85,7 +85,7 @@ module Sass
|
|||
|
||||
def string
|
||||
return unless @scanner.scan(REGULAR_EXPRESSIONS[:string])
|
||||
[:string, Script::String.new(@scanner[1].gsub(/\\(.)/, '\1'))]
|
||||
[:string, Script::String.new(@scanner[1].gsub(/\\([^0-9a-f])/, '\1').gsub(/\\([0-9a-f]{1,4})/, "\\\\\\1"))]
|
||||
end
|
||||
|
||||
def number
|
||||
|
|
|
@ -5,8 +5,18 @@ require 'sass/engine'
|
|||
class SassScriptTest < Test::Unit::TestCase
|
||||
include Sass::Script
|
||||
|
||||
def eval(str, environment = {})
|
||||
Sass::Script.resolve(str, 0, environment)
|
||||
end
|
||||
|
||||
def test_color_checks_input
|
||||
assert_raise(Sass::SyntaxError, "Color values must be between 0 and 255") {Color.new([1, 2, -1])}
|
||||
assert_raise(Sass::SyntaxError, "Color values must be between 0 and 255") {Color.new([256, 2, 3])}
|
||||
end
|
||||
|
||||
def test_string_escapes
|
||||
assert_equal '"', eval("\"\\\"\"")
|
||||
assert_equal "\\", eval("\"\\\\\"")
|
||||
assert_equal "\\02fa", eval("\"\\02fa\"")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue