servo: Merge #17218 - Don't accept an extra token at the end of transform property (from canaltinova:transform-bug); r=emilio
authorNazım Can Altınova <canaltinova@gmail.com>
Thu, 08 Jun 2017 03:37:44 -0700
changeset 363010 358e2a5aa1412742f295ec8c5492e46025dd4e29
parent 363007 a08ea7f330370f90091ef1ee4b3a814bc2112755
child 363011 8a1615be322cb623d5f4e1dd7d85aae1c6c6b18c
push id31994
push usercbook@mozilla.com
push dateFri, 09 Jun 2017 10:56:24 +0000
treeherdermozilla-central@7c9d96bbc400 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs17218
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #17218 - Don't accept an extra token at the end of transform property (from canaltinova:transform-bug); r=emilio The lack of `input.try` usage makes transform property to accept values like `rotate(70deg)foo`. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 09b4f79ed35fdd5f16a66e3524742ea55a1805bd
servo/components/style/properties/longhand/box.mako.rs
servo/tests/unit/style/parsing/box_.rs
--- a/servo/components/style/properties/longhand/box.mako.rs
+++ b/servo/components/style/properties/longhand/box.mako.rs
@@ -951,17 +951,17 @@
     fn parse_internal(context: &ParserContext, input: &mut Parser, prefixed: bool)
         -> Result<SpecifiedValue,()> {
         if input.try(|input| input.expect_ident_matching("none")).is_ok() {
             return Ok(SpecifiedValue(Vec::new()))
         }
 
         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,
             };
             match_ignore_ascii_case! {
                 &name,
                 "matrix" => {
                     try!(input.parse_nested_block(|input| {
                         // Standard matrix parsing.
--- a/servo/tests/unit/style/parsing/box_.rs
+++ b/servo/tests/unit/style/parsing/box_.rs
@@ -26,8 +26,15 @@ fn test_will_change() {
 #[test]
 fn test_transform_translate() {
     use style::properties::longhands::transform;
     assert_roundtrip_with_context!(transform::parse, "translate(2px)");
     assert_roundtrip_with_context!(transform::parse, "translate(2px, 5px)");
     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);
+}