Permalink
Browse files

Disallow null in String operations.

Update #374
  • Loading branch information...
1 parent 709c5a9 commit a78bba75ced528f00332877763677aad1d59d1ed @nex3 nex3 committed May 11, 2012
Showing with 7 additions and 11 deletions.
  1. +2 −3 doc-src/SASS_REFERENCE.md
  2. +1 −2 lib/sass/script/operation.rb
  3. +4 −6 test/sass/script_test.rb
@@ -935,12 +935,11 @@ is compiled to:
p:before {
content: "I ate 15 pies!"; }
-Null values are treated as empty strings for string operations and interpolations:
+Null values are treated as empty strings for string interpolation:
$value: null;
p:before {
- content: "I ate #{$value} pies!";
- font-family: sans- + $value; }
+ content: "I ate #{$value} pies!"; }
is compiled to:
@@ -82,8 +82,7 @@ def _perform(environment)
literal2 = @operand2.perform(environment)
- literal_types = [literal1.class, literal2.class]
- if !literal_types.include?(String) && literal_types.include?(Null)
+ if literal1.is_a?(Null) || literal2.is_a?(Null)
raise Sass::SyntaxError.new("Invalid null operation: \"#{literal1.inspect} #{@operator} #{literal2.inspect}\".")
end
View
@@ -320,12 +320,6 @@ def test_string_ops
assert_equal "true-1", resolve('true - 1')
assert_equal '"foo"/"bar"', resolve('"foo" / "bar"')
assert_equal "true/1", resolve('true / 1')
- assert_equal "foo", resolve('"foo" + null')
- assert_equal "foo", resolve('null + "foo"')
- assert_equal '"foo"-', resolve('"foo" - null')
- assert_equal '-"foo"', resolve('null - "foo"')
- assert_equal '"foo"/', resolve('"foo" / null')
- assert_equal '/"foo"', resolve('null / "foo"')
assert_equal '-"bar"', resolve("- 'bar'")
assert_equal "-true", resolve('- true')
@@ -373,6 +367,10 @@ def test_null_ops
'Invalid null operation: "1 gt null".') {eval("1 > null")}
assert_raise_message(Sass::SyntaxError,
'Invalid null operation: "null lt 1".') {eval("null < 1")}
+ assert_raise_message(Sass::SyntaxError,
+ 'Invalid null operation: "null plus null".') {eval("null + null")}
+ assert_raise_message(Sass::SyntaxError,
+ 'Invalid null operation: ""foo" plus null".') {eval("foo + null")}
end
def test_equals

0 comments on commit a78bba7

Please sign in to comment.