Skip to content

fix handling of some malformed css #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2018

Conversation

flinst
Copy link

@flinst flinst commented Aug 23, 2018

This fixes two incompatibilities between shady-css-parser
and browsers.

  1. If the css is missing a closing brace like
    div { color:red
    then Shady drops the last rule, but browsers keep it.

  2. If a css ruleset has an empty selector like
    /*empty*/ { color: red }
    div { color: blue }
    then Shady discards the { } and produces this:
    color:red;div { color: blue; }
    which has an entirely different meaning.

    Browsers parse the empty-selector block, but then ignore it
    as invalid.

    For this case, we could either make Shady keep the block
    or drop the block. I decided to keep the block, because
    Shady generally passes through many other not-quite-valid
    css text that browsers would ignore.

This fixes two incompatibilities between shady-css-parser
and browsers.

1. If the css is missing a closing brace like
       div { color:red
   then Shady drops the last rule, but browsers keep it.

2. If a css ruleset has an empty selector like
       /*empty*/ { color: red }
       div { color: blue }
   then Shady discards the { } and produces this:
       color:red;div { color: blue; }
   which has an entirely different meaning.

   Browsers parse the empty-selector block, but then ignore it
   as invalid.

   For this case, we could either make Shady keep the block
   or drop the block. I decided to keep the block, because
   Shady generally passes through many other not-quite-valid
   css text that browsers would ignore.
@maribezler maribezler merged commit e15ca75 into maribezler:master Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants