1 | [package]
|
2 | name = "quick-xml"
|
3 | version = "0.31.0"
|
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 | include = ["src/*" , "LICENSE-MIT.md" , "README.md" ]
|
15 |
|
16 | [dependencies]
|
17 | document-features = { version = "0.2" , optional = true }
|
18 | encoding_rs = { version = "0.8" , optional = true }
|
19 | serde = { version = ">=1.0.100" , optional = true }
|
20 | tokio = { version = "1.10" , optional = true, default-features = false, features = ["io-util" ] }
|
21 | memchr = "2.1"
|
22 | arbitrary = { version = "1" , features = ["derive" ], optional = true }
|
23 |
|
24 | [dev-dependencies]
|
25 | criterion = "0.4"
|
26 | pretty_assertions = "1.4"
|
27 | regex = "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
|
30 | serde_derive = { version = "1.0.79" }
|
31 | serde-value = "0.7"
|
32 | tokio = { version = "1.21" , default-features = false, features = ["macros" , "rt" ] }
|
33 | tokio-test = "0.4"
|
34 |
|
35 | [lib]
|
36 | bench = false
|
37 |
|
38 | [[bench]]
|
39 | name = "microbenches"
|
40 | harness = false
|
41 | path = "benches/microbenches.rs"
|
42 |
|
43 | [[bench]]
|
44 | name = "macrobenches"
|
45 | harness = false
|
46 | path = "benches/macrobenches.rs"
|
47 |
|
48 | [features]
|
49 | default = []
|
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
|
55 | async-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
|
112 | encoding = ["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
|
121 | escape-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
|
168 | overlapped-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
|
177 | serde-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.
|
184 | serialize = ["serde" ] # "dep:" prefix only avalible from Rust 1.60
|
185 |
|
186 | [package.metadata.docs.rs]
|
187 | # document all features
|
188 | all-features = true
|
189 | # defines the configuration attribute `docs_rs` to enable feature requirements
|
190 | # See https://stackoverflow.com/questions/61417452
|
191 | rustdoc-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]]
|
197 | name = "encodings"
|
198 | required-features = ["encoding" ]
|
199 | path = "tests/encodings.rs"
|
200 |
|
201 | [[test]]
|
202 | name = "serde_roundtrip"
|
203 | required-features = ["serialize" ]
|
204 | path = "tests/serde_roundtrip.rs"
|
205 |
|
206 | [[test]]
|
207 | name = "serde-de"
|
208 | required-features = ["serialize" ]
|
209 | path = "tests/serde-de.rs"
|
210 |
|
211 | [[test]]
|
212 | name = "serde-de-enum"
|
213 | required-features = ["serialize" ]
|
214 | path = "tests/serde-de-enum.rs"
|
215 |
|
216 | [[test]]
|
217 | name = "serde-de-seq"
|
218 | required-features = ["serialize" ]
|
219 | path = "tests/serde-de-seq.rs"
|
220 |
|
221 | [[test]]
|
222 | name = "serde-se"
|
223 | required-features = ["serialize" ]
|
224 | path = "tests/serde-se.rs"
|
225 |
|
226 | [[test]]
|
227 | name = "serde-migrated"
|
228 | required-features = ["serialize" ]
|
229 | path = "tests/serde-migrated.rs"
|
230 |
|
231 | [[test]]
|
232 | name = "serde-issues"
|
233 | required-features = ["serialize" ]
|
234 | path = "tests/serde-issues.rs"
|
235 |
|
236 | [[test]]
|
237 | name = "async-tokio"
|
238 | required-features = ["async-tokio" ]
|
239 | path = "tests/async-tokio.rs"
|
240 |
|
241 | [[example]]
|
242 | name = "read_nodes_serde"
|
243 | required-features = ["serialize" ]
|
244 | path = "examples/read_nodes_serde.rs"
|
245 | |