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