is_ident_start reads the wrong byte for a hyphen before a backslash
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 88/100
Direzione di ricerca
Inizia da src/tokenizer.rs:895 ed esegui il riproduttore Rust con le funzionalità predefinite. Controlla la decisione di inizio dell'identificatore per un trattino prima di una sequenza barra rovesciata-a capo, quindi verifica che i tre input segnalati producano i tipi e i valori di token previsti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
When a - is followed by a backslash that begins an escape, the check that decides whether an identifier starts here reads the wrong byte. A backslash right before a newline is an invalid escape and cannot start an identifier, so -\<newline> is mis-tokenized.
Reproducer
cssparser 0.37.0, default features.
use cssparser::{Parser, ParserInput};
fn main() {
let mut pi = ParserInput::new("1-\\\n");
let mut p = Parser::new(&mut pi);
let a = p.next().unwrap().clone();
// cssparser: Dimension { value: 1.0, int_value: Some(1), unit: "-" }
println!("{:?}", a);
}
Observed vs expected
Observed for 1-\<newline>: the tokens are Dimension { value: 1.0, unit: "-" } then Delim('\\'). For -\<newline> the first token is Ident("-"). For #-\<newline> the first token is IDHash("-").
Expected per CSS Syntax Level 3, matched by tinycss2: 1-\<newline> gives Number(1), Delim('-'), Delim('\\'). -\<newline> gives Delim('-') then Delim('\\'). #-\<newline> gives a hash token Hash("-") with the unrestricted type flag, not an id hash.
Root cause
src/tokenizer.rs:895. The would-start-an-identifier test reads the byte after the backslash to decide if -\ begins an identifier. A backslash directly before a newline is not a valid escape, but the offset used skips the backslash and reads the newline as though it were escaped.
Scope
A hyphen before an invalid escape produces a unit, an identifier, or an id hash that the input never held. A consumer that keys on token type, such as a linter or a minifier, then acts on tokens the source did not contain.
- Lingua principale
- Rust
- Stelle
- 869
- Fork
- 152
- Merge medio
- 15h 8m
- PR unite (30g)
- 12
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di servo/rust-cssparser
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
servo/rust-cssparser#439 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
servo/rust-cssparser#434 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
servo/rust-cssparser#438 · 3 commenti · 1 reazione ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
servo/rust-cssparser#436 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
servo/rust-cssparser#423 · 5 commenti ·
Tutte le issue di servo/rust-cssparser
Issue simili
-
risk:low runtime status:in-progress type:test
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
zeroclaw-labs/zeroclaw#11023 ·
-
good first issue refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
bevyengine/bevy#25861 ·