Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Disallow null in String operations.

Update #374
  • Loading branch information...
commit a78bba75ced528f00332877763677aad1d59d1ed 1 parent 709c5a9
@nex3 nex3 authored
View
5 doc-src/SASS_REFERENCE.md
@@ -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:
View
3  lib/sass/script/operation.rb
@@ -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
10 test/sass/script_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.