servo / servo/rust-cssparser

BadString recovery issues

Open
#393 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
869
Forks
152
Avg merge
15h 8m
Merged PRs (30d)
12

Description

According to CSS forward-compatible parsing rules, if a CSS declaration fails to parse the parser should forward until whichever is closer of EOF and a semicolon then resume parsing.

cssparser doesn't seem to allow for this when trying to parse a "bad string" containing a newline e.g.

text-decoration: '\n'; color: green

Once the parser has triggered a BadString error, the next token is

    QuotedString(
        "; color: green",
    ),

This is not the behaviour of browsers e.g. if this is added as a style value to an element in firefox, the text-decoration is flagged as an invalid property value, and the color declaration is parsed properly and applied.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in rust-cssparser's BadString recovery path and reproduce the declaration text-decoration: '\n'; color: green. Compare the tokenization and recovery with Firefox's behavior; done means the invalid declaration is rejected while the following color declaration is parsed and applied.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, rust
Domain
compilers, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.