Skip to content

Commit ab06d5e

Browse files
committed
Change default quote level from Full to Partial
1 parent 9fb181a commit ab06d5e

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

Changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ configuration is serializable.
2020
- [#677]: Added methods `config()` and `config_mut()` to inspect and change the parser
2121
configuration. Previous builder methods on `Reader` / `NsReader` was replaced by
2222
direct access to fields of config using `reader.config_mut().<...>`.
23-
- #[#684]: Added a method `Config::enable_all_checks` to turn on or off all
23+
- [#684]: Added a method `Config::enable_all_checks` to turn on or off all
2424
well-formedness checks.
2525

2626
### Bug Fixes
@@ -47,7 +47,9 @@ configuration is serializable.
4747
- [#684]: Now `<??>` parsed as `Event::PI` with empty content instead of raising
4848
syntax error.
4949
- [#684]: Now `<?xml?>` parsed as `Event::Decl` instead of `Event::PI`.
50+
- [#362]: Now default quote level is `QuoteLevel::Partial` when using serde serializer.
5051

52+
[#362]: https://github.com/tafia/quick-xml/issues/362
5153
[#513]: https://github.com/tafia/quick-xml/issues/513
5254
[#622]: https://github.com/tafia/quick-xml/issues/622
5355
[#675]: https://github.com/tafia/quick-xml/pull/675

src/se/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ impl<'w, 'r, W: Write> Serializer<'w, 'r, W> {
461461
Self {
462462
ser: ContentSerializer {
463463
writer,
464-
level: QuoteLevel::Full,
464+
level: QuoteLevel::Partial,
465465
indent: Indent::None,
466466
write_indent: false,
467467
expand_empty_elements: false,
@@ -526,7 +526,7 @@ impl<'w, 'r, W: Write> Serializer<'w, 'r, W> {
526526
Ok(Self {
527527
ser: ContentSerializer {
528528
writer,
529-
level: QuoteLevel::Full,
529+
level: QuoteLevel::Partial,
530530
indent: Indent::None,
531531
write_indent: false,
532532
expand_empty_elements: false,

tests/serde-se.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,13 +1807,13 @@ mod with_root {
18071807
serialize_as!(char_lt: '<' => "<root>&lt;</root>");
18081808
serialize_as!(char_gt: '>' => "<root>&gt;</root>");
18091809
serialize_as!(char_amp: '&' => "<root>&amp;</root>");
1810-
serialize_as!(char_apos: '\'' => "<root>&apos;</root>");
1811-
serialize_as!(char_quot: '"' => "<root>&quot;</root>");
1810+
serialize_as!(char_apos: '\'' => "<root>'</root>");
1811+
serialize_as!(char_quot: '"' => "<root>\"</root>");
18121812
// FIXME: Probably we should trim only for specified types when deserialize
18131813
serialize_as_only!(char_space: ' ' => "<root> </root>");
18141814

18151815
serialize_as!(str_non_escaped: "non-escaped string"; &str => "<root>non-escaped string</root>");
1816-
serialize_as!(str_escaped: "<\"escaped & string'>"; String => "<root>&lt;&quot;escaped &amp; string&apos;&gt;</root>");
1816+
serialize_as!(str_escaped: "<\"escaped & string'>"; String => "<root>&lt;\"escaped &amp; string'&gt;</root>");
18171817

18181818
err!(bytes: Bytes(b"<\"escaped & bytes'>") => Unsupported("`serialize_bytes` not supported yet"));
18191819

@@ -1839,7 +1839,7 @@ mod with_root {
18391839
serialize_as!(tuple:
18401840
// Use to_string() to get owned type that is required for deserialization
18411841
("<\"&'>".to_string(), "with\t\r\n spaces", 3usize)
1842-
=> "<root>&lt;&quot;&amp;&apos;&gt;</root>\
1842+
=> "<root>&lt;\"&amp;'&gt;</root>\
18431843
<root>with\t\r\n spaces</root>\
18441844
<root>3</root>");
18451845
serialize_as!(tuple_struct:

0 commit comments

Comments
 (0)