From 51066436fa91d08846a76bba8c63701870d66375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Thu, 8 Jun 2017 02:32:45 +0300 Subject: [PATCH] Don't accept an extra token at the end of transform property --- components/style/properties/longhand/box.mako.rs | 2 +- tests/unit/style/parsing/box_.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 0b358609ab70..03891fe3b54d 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -956,7 +956,7 @@ ${helpers.predefined_type("scroll-snap-coordinate", let mut result = Vec::new(); loop { - let name = match input.expect_function() { + let name = match input.try(|i| i.expect_function()) { Ok(name) => name, Err(_) => break, }; diff --git a/tests/unit/style/parsing/box_.rs b/tests/unit/style/parsing/box_.rs index c603eb6f48d0..6d3778942fa8 100644 --- a/tests/unit/style/parsing/box_.rs +++ b/tests/unit/style/parsing/box_.rs @@ -31,3 +31,10 @@ fn test_transform_translate() { assert!(parse(transform::parse, "translate(2px foo)").is_err()); assert!(parse(transform::parse, "perspective(-10px)").is_err()); } + +#[test] +fn test_unexhausted_transform() { + use style::properties::longhands::transform; + assert_parser_exhausted!(transform::parse, "rotate(70deg)foo", false); + assert_parser_exhausted!(transform::parse, "rotate(70deg) foo", false); +}