1 | [package]
|
2 | name = "quick-xml"
|
3 | version = "0.37.4"
|
4 | description = "High performance xml reader and writer"
|
5 | edition = "2021"
|
6 |
|
7 | documentation = "https://docs.rs/quick-xml"
|
8 | repository = "https://github.com/tafia/quick-xml"
|
9 |
|
10 | keywords = ["xml" , "serde" , "parser" , "writer" , "html" ]
|
11 | categories = ["asynchronous" , "encoding" , "parsing" , "parser-implementations" ]
|
12 | license = "MIT"
|
13 | rust-version = "1.56"
|
14 | # We exclude tests & examples & benches to reduce the size of a package.
|
15 | # Unfortunately, this is source of warnings in latest cargo when packaging:
|
16 | # > warning: ignoring {context} `{name}` as `{path}` is not included in the published package
|
17 | # That may become unnecessary once https://github.com/rust-lang/cargo/issues/13491
|
18 | # will be resolved
|
19 | include = ["src/*" , "LICENSE-MIT.md" , "README.md" ]
|
20 |
|
21 | [dependencies]
|
22 | arbitrary = { version = "1" , features = ["derive" ], optional = true }
|
23 | document-features = { version = "0.2" , optional = true }
|
24 | encoding_rs = { version = "0.8" , optional = true }
|
25 | serde = { version = ">=1.0.139" , optional = true }
|
26 | tokio = { version = "1.10" , optional = true, default-features = false, features = ["io-util" ] }
|
27 | memchr = "2.1"
|
28 |
|
29 | [dev-dependencies]
|
30 | criterion = "0.4"
|
31 | pretty_assertions = "1.4"
|
32 | regex = "1"
|
33 | # https://github.com/serde-rs/serde/issues/1904 is fixed since 1.0.206
|
34 | # serde does not follow semver in numbering and their dependencies, so we specifying patch here
|
35 | serde_derive = { version = "1.0.206" }
|
36 | serde-value = "0.7"
|
37 | tokio = { version = "1.21" , default-features = false, features = ["macros" , "rt" ] }
|
38 | tokio-test = "0.4"
|
39 |
|
40 | [lib]
|
41 | bench = false
|
42 |
|
43 | [[bench]]
|
44 | name = "microbenches"
|
45 | harness = false
|
46 | path = "benches/microbenches.rs"
|
47 |
|
48 | [[bench]]
|
49 | name = "macrobenches"
|
50 | harness = false
|
51 | path = "benches/macrobenches.rs"
|
52 |
|
53 | [features]
|
54 | default = []
|
55 |
|
56 | ## Enables support for asynchronous reading and writing from `tokio`'s IO-Traits by enabling
|
57 | ## [reading events] from types implementing [`tokio::io::AsyncBufRead`].
|
58 | ##
|
59 | ## [reading events]: crate::reader::Reader::read_event_into_async
|
60 | async-tokio = ["tokio" ]
|
61 |
|
62 | ## Enables support of non-UTF-8 encoded documents. Encoding will be inferred from
|
63 | ## the XML declaration if it is found, otherwise UTF-8 is assumed.
|
64 | ##
|
65 | ## Currently, only ASCII-compatible encodings are supported. For example,
|
66 | ## UTF-16 will not work (therefore, `quick-xml` is not [standard compliant]).
|
67 | ##
|
68 | ## Thus, quick-xml supports all encodings of [`encoding_rs`] except these:
|
69 | ## - [UTF-16BE]
|
70 | ## - [UTF-16LE]
|
71 | ## - [ISO-2022-JP]
|
72 | ##
|
73 | ## You should stop processing a document when one of these encodings is detected,
|
74 | ## because generated events can be wrong and do not reflect a real document structure!
|
75 | ##
|
76 | ## Because these are the only supported encodings that are not ASCII compatible, you can
|
77 | ## check for them:
|
78 | ##
|
79 | ## ```
|
80 | ## use quick_xml::events::Event;
|
81 | ## use quick_xml::reader::Reader;
|
82 | ##
|
83 | ## # fn to_utf16le_with_bom(string: &str) -> Vec<u8> {
|
84 | ## # let mut bytes = Vec::new();
|
85 | ## # bytes.extend_from_slice(&[0xFF, 0xFE]); // UTF-16 LE BOM
|
86 | ## # for ch in string.encode_utf16() {
|
87 | ## # bytes.extend_from_slice(&ch.to_le_bytes());
|
88 | ## # }
|
89 | ## # bytes
|
90 | ## # }
|
91 | ## let xml = to_utf16le_with_bom(r#"<?xml encoding='UTF-16'><element/>"#);
|
92 | ## let mut reader = Reader::from_reader(xml.as_ref());
|
93 | ## reader.config_mut().trim_text(true);
|
94 | ##
|
95 | ## let mut buf = Vec::new();
|
96 | ## let mut unsupported = false;
|
97 | ## loop {
|
98 | ## if !reader.decoder().encoding().is_ascii_compatible() {
|
99 | ## unsupported = true;
|
100 | ## break;
|
101 | ## }
|
102 | ## buf.clear();
|
103 | ## match reader.read_event_into(&mut buf).unwrap() {
|
104 | ## Event::Eof => break,
|
105 | ## _ => {}
|
106 | ## }
|
107 | ## }
|
108 | ## assert_eq!(unsupported, true);
|
109 | ## ```
|
110 | ## This restriction will be eliminated once issue [#158] is resolved.
|
111 | ##
|
112 | ## [standard compliant]: https://www.w3.org/TR/xml11/#charencoding
|
113 | ## [UTF-16BE]: encoding_rs::UTF_16BE
|
114 | ## [UTF-16LE]: encoding_rs::UTF_16LE
|
115 | ## [ISO-2022-JP]: encoding_rs::ISO_2022_JP
|
116 | ## [#158]: https://github.com/tafia/quick-xml/issues/158
|
117 | encoding = ["encoding_rs" ]
|
118 |
|
119 | ## Enables support for recognizing all [HTML 5 entities] in [`unescape`]
|
120 | ## function. The full list of entities also can be found in
|
121 | ## <https://html.spec.whatwg.org/entities.json>.
|
122 | ##
|
123 | ## [HTML 5 entities]: https://dev.w3.org/html5/html-author/charref
|
124 | ## [`unescape`]: crate::escape::unescape
|
125 | escape-html = []
|
126 |
|
127 | ## This feature is for the Serde deserializer that enables support for deserializing
|
128 | ## lists where tags are overlapped with tags that do not correspond to the list.
|
129 | ##
|
130 | ## When this feature is enabled, the XML:
|
131 | ## ```xml
|
132 | ## <any-name>
|
133 | ## <item/>
|
134 | ## <another-item/>
|
135 | ## <item/>
|
136 | ## <item/>
|
137 | ## </any-name>
|
138 | ## ```
|
139 | ## could be deserialized to a struct:
|
140 | ## ```no_run
|
141 | ## # use serde::Deserialize;
|
142 | ## #[derive(Deserialize)]
|
143 | ## #[serde(rename_all = "kebab-case")]
|
144 | ## struct AnyName {
|
145 | ## item: Vec<()>,
|
146 | ## another_item: (),
|
147 | ## }
|
148 | ## ```
|
149 | ##
|
150 | ## When this feature is not enabled (default), only the first element will be
|
151 | ## associated with the field, and the deserialized type will report an error
|
152 | ## (duplicated field) when the deserializer encounters a second `<item/>`.
|
153 | ##
|
154 | ## Note, that enabling this feature can lead to high and even unlimited memory
|
155 | ## consumption, because deserializer needs to check all events up to the end of a
|
156 | ## container tag (`</any-name>` in this example) to figure out that there are no
|
157 | ## more items for a field. If `</any-name>` or even EOF is not encountered, the
|
158 | ## parsing will never end which can lead to a denial-of-service (DoS) scenario.
|
159 | ##
|
160 | ## Having several lists and overlapped elements for them in XML could also lead
|
161 | ## to quadratic parsing time, because the deserializer must check the list of
|
162 | ## events as many times as the number of sequence fields present in the schema.
|
163 | ##
|
164 | ## To reduce negative consequences, always [limit] the maximum number of events
|
165 | ## that [`Deserializer`] will buffer.
|
166 | ##
|
167 | ## This feature works only with `serialize` feature and has no effect if `serialize`
|
168 | ## is not enabled.
|
169 | ##
|
170 | ## [limit]: crate::de::Deserializer::event_buffer_size
|
171 | ## [`Deserializer`]: crate::de::Deserializer
|
172 | overlapped-lists = []
|
173 |
|
174 | ## Enables serialization of some quick-xml types using [`serde`]. This feature
|
175 | ## is rarely needed.
|
176 | ##
|
177 | ## This feature does NOT provide XML serializer or deserializer. You should use
|
178 | ## the `serialize` feature for that instead.
|
179 | # Cannot name "serde" to avoid clash with dependency.
|
180 | # "dep:" prefix only avalible from Rust 1.60
|
181 | serde-types = ["serde/derive" ]
|
182 |
|
183 | ## Enables support for [`serde`] serialization and deserialization. When this
|
184 | ## feature is enabled, quick-xml provides serializer and deserializer for XML.
|
185 | ##
|
186 | ## This feature does NOT enables serializaton of the types inside quick-xml.
|
187 | ## If you need that, use the `serde-types` feature.
|
188 | serialize = ["serde" ] # "dep:" prefix only avalible from Rust 1.60
|
189 |
|
190 | [package.metadata.docs.rs]
|
191 | # document all features
|
192 | all-features = true
|
193 |
|
194 | # Tests, benchmarks and examples doesn't included in package on crates.io,
|
195 | # so we need to specify a path, otherwise `cargo package` complains
|
196 | # That may become unnecessary once https://github.com/rust-lang/cargo/issues/13491
|
197 | # will be resolved
|
198 |
|
199 | [[test]]
|
200 | name = "async-tokio"
|
201 | required-features = ["async-tokio" ]
|
202 | path = "tests/async-tokio.rs"
|
203 |
|
204 | [[test]]
|
205 | name = "encodings"
|
206 | required-features = ["encoding" ]
|
207 | path = "tests/encodings.rs"
|
208 |
|
209 | [[test]]
|
210 | name = "html"
|
211 | required-features = ["escape-html" ]
|
212 | path = "tests/html.rs"
|
213 |
|
214 | [[test]]
|
215 | name = "serde_roundtrip"
|
216 | required-features = ["serialize" ]
|
217 | path = "tests/serde_roundtrip.rs"
|
218 |
|
219 | [[test]]
|
220 | name = "serde-de"
|
221 | required-features = ["serialize" ]
|
222 | path = "tests/serde-de.rs"
|
223 |
|
224 | [[test]]
|
225 | name = "serde-de-enum"
|
226 | required-features = ["serialize" ]
|
227 | path = "tests/serde-de-enum.rs"
|
228 |
|
229 | [[test]]
|
230 | name = "serde-de-seq"
|
231 | required-features = ["serialize" ]
|
232 | path = "tests/serde-de-seq.rs"
|
233 |
|
234 | [[test]]
|
235 | name = "serde-de-xsi"
|
236 | required-features = ["serialize" ]
|
237 | path = "tests/serde-de-xsi.rs"
|
238 |
|
239 | [[test]]
|
240 | name = "serde-se"
|
241 | required-features = ["serialize" ]
|
242 | path = "tests/serde-se.rs"
|
243 |
|
244 | [[test]]
|
245 | name = "serde-migrated"
|
246 | required-features = ["serialize" ]
|
247 | path = "tests/serde-migrated.rs"
|
248 |
|
249 | [[test]]
|
250 | name = "serde-issues"
|
251 | required-features = ["serialize" ]
|
252 | path = "tests/serde-issues.rs"
|
253 |
|
254 | [[example]]
|
255 | name = "read_nodes_serde"
|
256 | required-features = ["serialize" ]
|
257 | path = "examples/read_nodes_serde.rs"
|
258 |
|
259 | [[example]]
|
260 | name = "flattened_enum"
|
261 | required-features = ["serialize" ]
|
262 | path = "examples/flattened_enum.rs"
|
263 | |