File: quick-xml-0.38.diff

package info (click to toggle)
rust-bmap-parser 0.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,276 kB
  • sloc: makefile: 4
file content (87 lines) | stat: -rw-r--r-- 3,204 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
This patch is based on the commit described below taken from upstream
pull request 92, adapted for use in the Debian package by Peter Michael Green.

commit 8cf51a01c11c66e5da1148ed918d6e13df73131c
Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date:   Mon Oct 20 09:40:50 2025 +0000

    Add whitespace trimming for quick-xml 0.38 compatibility
    
    Co-authored-by: sjoerdsimons <22603932+sjoerdsimons@users.noreply.github.com>

Index: bmap-parser/src/bmap/xml.rs
===================================================================
--- bmap-parser.orig/src/bmap/xml.rs
+++ bmap-parser/src/bmap/xml.rs
@@ -4,11 +4,33 @@ use serde::Deserialize;
 use std::str::FromStr;
 use thiserror::Error;
 
+/// Custom deserializer that trims whitespace before parsing u64
+/// This is needed for compatibility with quick-xml 0.38 which changed
+/// how it handles whitespace in text content
+fn deserialize_trimmed_u64<'de, D>(deserializer: D) -> Result<u64, D::Error>
+where
+    D: serde::Deserializer<'de>,
+{
+    let s = String::deserialize(deserializer)?;
+    s.trim().parse().map_err(serde::de::Error::custom)
+}
+
+/// Custom deserializer that trims whitespace from strings
+/// This is needed for compatibility with quick-xml 0.38 which changed
+/// how it handles whitespace in text content
+fn deserialize_trimmed_string<'de, D>(deserializer: D) -> Result<String, D::Error>
+where
+    D: serde::Deserializer<'de>,
+{
+    let s = String::deserialize(deserializer)?;
+    Ok(s.trim().to_string())
+}
+
 #[derive(Debug, Deserialize)]
 struct Range {
     #[serde(rename = "@chksum")]
     chksum: String,
-    #[serde(rename = "$value")]
+    #[serde(rename = "$value", deserialize_with = "deserialize_trimmed_string")]
     range: String,
 }
 
@@ -23,17 +45,17 @@ struct BlockMap {
 struct Bmap {
     #[serde(rename = "@version")]
     version: String,
-    #[serde(rename = "ImageSize")]
+    #[serde(rename = "ImageSize", deserialize_with = "deserialize_trimmed_u64")]
     image_size: u64,
-    #[serde(rename = "BlockSize")]
+    #[serde(rename = "BlockSize", deserialize_with = "deserialize_trimmed_u64")]
     block_size: u64,
-    #[serde(rename = "BlocksCount")]
+    #[serde(rename = "BlocksCount", deserialize_with = "deserialize_trimmed_u64")]
     blocks_count: u64,
-    #[serde(rename = "MappedBlocksCount")]
+    #[serde(rename = "MappedBlocksCount", deserialize_with = "deserialize_trimmed_u64")]
     mapped_blocks_count: u64,
-    #[serde(rename = "ChecksumType")]
+    #[serde(rename = "ChecksumType", deserialize_with = "deserialize_trimmed_string")]
     checksum_type: String,
-    #[serde(rename = "BmapFileChecksum")]
+    #[serde(rename = "BmapFileChecksum", deserialize_with = "deserialize_trimmed_string")]
     bmap_file_checksum: String,
     #[serde(rename = "BlockMap")]
     block_map: BlockMap,
Index: bmap-parser/Cargo.toml
===================================================================
--- bmap-parser.orig/Cargo.toml
+++ bmap-parser/Cargo.toml
@@ -36,7 +36,7 @@ version = "1.0.20"
 version = "0.3.25"
 
 [dependencies.quick-xml]
-version = "0.31.0"
+version = ">= 0.31.0, < 0.39"
 features = ["serialize"]
 
 [dependencies.serde]