Skip to content

Strings containing semicolons are split by parse_declarations! #178

Open

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>}]

Activity

  1. grosser commented on Oct 18, 2025

    @grosser
    Contributor

    very similar to #177 ... and same solution that possibly only a full parser could solve that
    but PR welcome if you find a workaround maybe with some special logic for content, but could be tricky since the ; splitting is pretty early I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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