Dimension with an e-prefixed unit serializes to a number token
まだ誰も着手していません。
評価
調査の方向性
src/serializer.rs:107 の次元シリアライズ分岐から始め、識別子と衝突する可能性のある単位に対する既存のガードを追跡してください。e5 や e90 のような単位を使った reproducer をリグレッションケースとして使用し、シリアライズされた次元が同じ単位と値で再パースできることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
A Token::Dimension whose unit begins with e or E followed by a digit serializes to text that re-parses as a Number with a different value. The unit is written straight after the numeric value with no separation, so a value of 1 with unit e5 becomes 1e5, which is scientific notation for the number 100000.
Reproducer
cssparser 0.37.0, default features.
use cssparser::{Parser, ParserInput, ToCss, Token};
fn main() {
let mut pi = ParserInput::new("1\\65 5");
let mut p = Parser::new(&mut pi);
let t = p.next().unwrap().clone();
// Dimension { value: 1.0, int_value: Some(1), unit: "e5" }
let s = t.to_css_string();
assert_eq!(s, "1e5");
let mut pi2 = ParserInput::new(&s);
let mut p2 = Parser::new(&mut pi2);
let t2 = p2.next().unwrap().clone();
// Number { value: 100000.0 }
assert!(matches!(t2, Token::Number { .. }));
}
Observed vs expected
Observed: the dimension serializes to 1e5. Re-parsing 1e5 yields Number { value: 100000.0 }, so the unit is gone and the value is scaled by 100000. With unit e90 the input serializes to 1e90, which re-parses to Number { value: inf }.
Expected: the serialized form re-parses to the same dimension. CSS Syntax Level 3 requires a serialized token to round-trip. The serializer already guards a unit that would collide with an identifier, so the same guard fits a unit that could read as an exponent. Writing the unit with a leading escape, as in 1\65 5, blocks the exponent reading.
Root cause
src/serializer.rs:107. The dimension arm writes the value and then the unit with no check for a unit that starts with e or E and a digit.
Scope
Any consumer that serializes tokens and later re-parses them can read a wrong numeric value, or an infinity where the source held a finite dimension. The value token is also reachable by constructing a Token::Dimension directly, without parsing. Present on main as of the latest commit.
- 主要言語
- Rust
- スター
- 871
- フォーク
- 152
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 6
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
servo/rust-cssparser のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
servo/rust-cssparser#440 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
servo/rust-cssparser#434 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
servo/rust-cssparser#438 · コメント 3 件 · リアクション 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
servo/rust-cssparser#436 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
servo/rust-cssparser#423 · コメント 5 件 ·
servo/rust-cssparser の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
rust-windowing/winit#4731 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
area:cli bug priority:high
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
Anthropic streamed blocks without a content_block_stop are discarded対応中かも @Frun1na が今日担当しました。 オープンcomponent:sight
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
agentic-os-org/ANOLISA#4622 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信