Skip to content

Strings containing semicolons are split by parse_declarations! #178

@sarken

Description

@sarken

parse_declarations! splits blocks on semicolons unless the the semicolon appears inside parentheses. Because there's no equivalent exception for quotation marks, strings containing semicolons get split. This means we lose any text after the semicolon.

For example, this CSS

.test-1 {
  display: grid;
  content: "I came; I saw; I conquered.";
}

gets split into the following declarations, eating a chunk of the content value:

rules:
 #<CssParser::RuleSet:0x0000000122194150
  @declarations=
   #<CssParser::RuleSet::Declarations:0x0000000122193d18
    @declarations=
     {"display" => #<CssParser::RuleSet::Declarations::Value:0x00000001221932c8 @important=false, @value="grid">,
      "content" => #<CssParser::RuleSet::Declarations::Value:0x0000000122192dc8 @important=false, @value="\"I came">}>,
  @selectors=[".test-1"],
  @specificity=nil>}]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions