1[package]
2name = "quick-xml"
3version = "0.37.4"
4description = "High performance xml reader and writer"
5edition = "2021"
6
7documentation = "https://docs.rs/quick-xml"
8repository = "https://github.com/tafia/quick-xml"
9
10keywords = ["xml", "serde", "parser", "writer", "html"]
11categories = ["asynchronous", "encoding", "parsing", "parser-implementations"]
12license = "MIT"
13rust-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
19include = ["src/*", "LICENSE-MIT.md", "README.md"]
20
21[dependencies]
22arbitrary = { version = "1", features = ["derive"], optional = true }
23document-features = { version = "0.2", optional = true }
24encoding_rs = { version = "0.8", optional = true }
25serde = { version = ">=1.0.139", optional = true }
26tokio = { version = "1.10", optional = true, default-features = false, features = ["io-util"] }
27memchr = "2.1"
28
29[dev-dependencies]
30criterion = "0.4"
31pretty_assertions = "1.4"
32regex = "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
35serde_derive = { version = "1.0.206" }
36serde-value = "0.7"
37tokio = { version = "1.21", default-features = false, features = ["macros", "rt"] }
38tokio-test = "0.4"
39
40[lib]
41bench = false
42
43[[bench]]
44name = "microbenches"
45harness = false
46path = "benches/microbenches.rs"
47
48[[bench]]
49name = "macrobenches"
50harness = false
51path = "benches/macrobenches.rs"
52
53[features]
54default = []
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
60async-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
117encoding = ["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
125escape-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
172overlapped-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
181serde-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.
188serialize = ["serde"] # "dep:" prefix only avalible from Rust 1.60
189
190[package.metadata.docs.rs]
191# document all features
192all-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]]
200name = "async-tokio"
201required-features = ["async-tokio"]
202path = "tests/async-tokio.rs"
203
204[[test]]
205name = "encodings"
206required-features = ["encoding"]
207path = "tests/encodings.rs"
208
209[[test]]
210name = "html"
211required-features = ["escape-html"]
212path = "tests/html.rs"
213
214[[test]]
215name = "serde_roundtrip"
216required-features = ["serialize"]
217path = "tests/serde_roundtrip.rs"
218
219[[test]]
220name = "serde-de"
221required-features = ["serialize"]
222path = "tests/serde-de.rs"
223
224[[test]]
225name = "serde-de-enum"
226required-features = ["serialize"]
227path = "tests/serde-de-enum.rs"
228
229[[test]]
230name = "serde-de-seq"
231required-features = ["serialize"]
232path = "tests/serde-de-seq.rs"
233
234[[test]]
235name = "serde-de-xsi"
236required-features = ["serialize"]
237path = "tests/serde-de-xsi.rs"
238
239[[test]]
240name = "serde-se"
241required-features = ["serialize"]
242path = "tests/serde-se.rs"
243
244[[test]]
245name = "serde-migrated"
246required-features = ["serialize"]
247path = "tests/serde-migrated.rs"
248
249[[test]]
250name = "serde-issues"
251required-features = ["serialize"]
252path = "tests/serde-issues.rs"
253
254[[example]]
255name = "read_nodes_serde"
256required-features = ["serialize"]
257path = "examples/read_nodes_serde.rs"
258
259[[example]]
260name = "flattened_enum"
261required-features = ["serialize"]
262path = "examples/flattened_enum.rs"
263