Ignore undeclared element when a $value field is present

オープン
#596 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rust
領域
backend

調査の方向性

Start by reading the deserialization handling for the rename="$value" field and compare it with the $text path; the issue provides a minimal Rust example that reproduces the UnexpectedStart error for <Foo/>. Determine whether undeclared elements should be ignored in this case, then add a regression test for the chosen behavior. The issue has had no comment for over three years, so check for maintainer guidance before starting.

索引モデルが issue の本文から書いたものです。

説明

enhancement help wanted serde

The default behaviour of ignoring XML elements that are not declared is very useful when dealing with XML that follows an extensible schema. However, including a rename="$value" field changes this behaviour, and undeclared elements generate an UnexpectedStart parse error.

#[derive(Debug, Default, Serialize, Deserialize)]
struct Root {
    #[serde(rename = "$value")]
    content: Option<String>,
}

let xml = r#"<Root><Foo/></Root>"#;
let r1: Result<Root, quick_xml::DeError> = quick_xml::de::from_str(xml);
//  Parse error: UnexpectedStart([70, 111, 111])

If the rename = "$value" is replaced by rename = "$text" then the problem does not arise (parsing is successful and the Foo element is ignored). Is this the intended behaviour?

主要言語
Rust
スター
1.6k
フォーク
299
平均マージ
2日 4時間
マージ済み PR(30日)
9

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tafia/quick-xml のほかの issue

tafia/quick-xml の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。