Skip to content

list.comma() and list.space() split on separators inside CSS comments #2161

Closed

Description

@00200200

list.comma() / list.space() / list.split() already skip separators inside quotes and functions, but they still treat , / spaces inside /* … */ comments as real separators.

const { list, Rule } = require('postcss')

list.comma('a, /* , */ b')
// actual:   ['a', '/*', '*/ b']
// expected: ['a', '/* , */ b']

list.space('f(/* ) */ a)')
// actual:   ['f(/* )', '*/', 'a)']
// expected: ['f(/* ) */ a)']

new Rule({ selector: 'a /* , */, b' }).selectors
// actual:   ['a /*', '*/', 'b']
// expected: ['a /* , */', 'b']

Rule#selectors is implemented as list.comma(this.selector), so any selector string that still contains comments (programmatic trees, custom syntax, or raw sources) is split incorrectly.

The parser itself strips comments out of selectors and declaration values, which is why this does not show up on a typical parse() round-trip. The public list.* helpers are documented as a safe split, though, and they already special-case quotes, functions, and escapes.

Activity

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