mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Require spaces around operators in calc() (fixes #15486)
This commit is contained in:
parent
8b60a409c1
commit
0138bbcdd1
3 changed files with 37 additions and 10 deletions
|
@ -584,19 +584,33 @@ impl CalcLengthOrPercentage {
|
||||||
let mut products = Vec::new();
|
let mut products = Vec::new();
|
||||||
products.push(try!(CalcLengthOrPercentage::parse_product(input, expected_unit)));
|
products.push(try!(CalcLengthOrPercentage::parse_product(input, expected_unit)));
|
||||||
|
|
||||||
while let Ok(token) = input.next() {
|
loop {
|
||||||
match token {
|
let position = input.position();
|
||||||
Token::Delim('+') => {
|
match input.next_including_whitespace() {
|
||||||
|
Ok(Token::WhiteSpace(_)) => {
|
||||||
|
match input.next() {
|
||||||
|
Ok(Token::Delim('+')) => {
|
||||||
products.push(try!(CalcLengthOrPercentage::parse_product(input, expected_unit)));
|
products.push(try!(CalcLengthOrPercentage::parse_product(input, expected_unit)));
|
||||||
}
|
}
|
||||||
Token::Delim('-') => {
|
|
||||||
|
Ok(Token::Delim('-')) => {
|
||||||
let mut right = try!(CalcLengthOrPercentage::parse_product(input, expected_unit));
|
let mut right = try!(CalcLengthOrPercentage::parse_product(input, expected_unit));
|
||||||
right.values.push(CalcValueNode::Number(-1.));
|
right.values.push(CalcValueNode::Number(-1.));
|
||||||
products.push(right);
|
products.push(right);
|
||||||
}
|
}
|
||||||
_ => return Err(())
|
|
||||||
|
_ => {
|
||||||
|
return Err(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
input.reset(position);
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Ok(CalcSumNode { products: products })
|
Ok(CalcSumNode { products: products })
|
||||||
}
|
}
|
||||||
|
|
12
tests/unit/style/parsing/length.rs
Normal file
12
tests/unit/style/parsing/length.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use parsing::parse;
|
||||||
|
use style::parser::Parse;
|
||||||
|
use style::values::specified::length::Length;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_calc() {
|
||||||
|
assert!(parse(Length::parse, "calc(1px+ 2px)").is_err());
|
||||||
|
}
|
|
@ -87,6 +87,7 @@ mod font;
|
||||||
mod image;
|
mod image;
|
||||||
mod inherited_box;
|
mod inherited_box;
|
||||||
mod inherited_text;
|
mod inherited_text;
|
||||||
|
mod length;
|
||||||
mod mask;
|
mod mask;
|
||||||
mod outline;
|
mod outline;
|
||||||
mod position;
|
mod position;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue