From c7ed931276d860272705d83244ab07d20e2e6793 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sun, 12 Mar 2017 03:58:51 +0530 Subject: [PATCH] text-overflow accepts only valid values for the second part of value Fixes: https://github.com/servo/servo/issues/15491 --- components/style/properties/longhand/text.mako.rs | 2 +- tests/unit/style/parsing/text_overflow.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index f5769fa26be..9c78d8e7e1e 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -51,7 +51,7 @@ } pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { let first = try!(Side::parse(context, input)); - let second = Side::parse(context, input).ok(); + let second = input.try(|input| Side::parse(context, input)).ok(); Ok(SpecifiedValue { first: first, second: second, diff --git a/tests/unit/style/parsing/text_overflow.rs b/tests/unit/style/parsing/text_overflow.rs index d8c2a2323f4..fd2b6b91cab 100644 --- a/tests/unit/style/parsing/text_overflow.rs +++ b/tests/unit/style/parsing/text_overflow.rs @@ -22,3 +22,13 @@ fn test_text_overflow() { assert_roundtrip_with_context!(text_overflow::parse, r#""x" "y""#); } + +#[test] +fn test_text_overflow_parser_exhaustion() { + use style::properties::longhands::text_overflow; + + assert_parser_exhausted!(text_overflow, r#"clip rubbish"#, false); + assert_parser_exhausted!(text_overflow, r#"clip"#, true); + assert_parser_exhausted!(text_overflow, r#"ellipsis"#, true); + assert_parser_exhausted!(text_overflow, r#"clip ellipsis"#, true); +}