Ignore undeclared element when a $value field is present

Đang mở
#596 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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?

Ngôn ngữ chính
Rust
Star
1.6k
Fork
299
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
9

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tafia/quick-xml

Tất cả issue của tafia/quick-xml

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.