Misparsed attribute selector

Aperta
#366 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@Ultroncn ci sta già lavorando.

Dal 18/11/2026.

  • #368 di @Ultroncn — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
frontend

Direzione di ricerca

Start by tracing how attribute selectors are parsed in the selector parser, using the reported [class=XXX'@{foo}-'] input to reproduce the lost XXX text. Check how the parser handles characters between the operator and a quoted value, then compare the result with the LESS example [class=~'@{foo}-']. Done means the parser either preserves that text or rejects the unsupported syntax consistently.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

It seems we allow and ignore everything between the operator and the quotes of value.

> require('postcss-selector-parser')(x => console.log(x.nodes[0].nodes[0])).processSync("[class=XXX'@{foo}-']")
<ref *1> Attribute {
  source: { start: { line: 1, column: 1 }, end: { line: 1, column: 20 } },
  sourceIndex: 0,
  _attribute: 'class',
  operator: '=',
  _value: '@{foo}-',
  _quoteMark: "'",
  raws: { value: "'@{foo}-'" },
  spaces: { before: '', after: '' },
  type: 'attribute',
  _constructed: true,
  parent: Selector {
    source: { start: [Object], end: [Object] },
    sourceIndex: 0,
    spaces: { before: '', after: '' },
    nodes: [ [Circular *1] ],
    type: 'selector',
    parent: Root {
      source: [Object],
      spaces: [Object],
      nodes: [Array],
      type: 'root',
      _error: [Function (anonymous)]
    }
  }
}

There is no information about XXX between = and '.

Found this when trying to support a valid selector in LESS [class=~'@{foo}-']

@foo: x;

[class=~'@{foo}-'] {
color: red;
  
}

LESS playground

This syntax seems not allowed in LESS 5, so I'm fine to reject it when parsing.

Lingua principale
JavaScript
Stelle
217
Fork
89
Merge medio
2g 1h
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di postcss/postcss-selector-parser

Tutte le issue di postcss/postcss-selector-parser

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.