From 497a6e3977c9a5fe1a25103b7133885f81d2b452 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 7 Nov 2018 19:45:51 +0100 Subject: EventReader,PlistEventWriter: Change use `base64::STANDARD` for `Data` Use `base64::STANDARD` instead of `base64::MIME` to encode `Plist::Data` types. Using `base64::MIME` formats the base64 string with: LineWrap::Wrap(76, LineEnding::CRLF) (https://docs.rs/base64/0.9.3/base64/constant.MIME.html) In an XML plist using `\n` line endings, the base64 string gets broken into `\r\n`, mixing line endings. The `STANDARD` configuration doesn't wrap lines at all, bypassing the whole problem. --- src/xml/reader.rs | 2 +- src/xml/writer.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/xml/reader.rs b/src/xml/reader.rs index 6642d59..6e6bb5e 100644 --- a/src/xml/reader.rs +++ b/src/xml/reader.rs @@ -67,7 +67,7 @@ impl EventReader { "false" => return Some(Ok(PlistEvent::BooleanValue(false))), "data" => { return Some(self.read_content(|s| { - let data = base64::decode_config(&s, base64::MIME) + let data = base64::decode_config(&s, base64::STANDARD) .map_err(|_| Error::InvalidData)?; Ok(PlistEvent::DataValue(data)) })) diff --git a/src/xml/writer.rs b/src/xml/writer.rs index e168128..8711601 100644 --- a/src/xml/writer.rs +++ b/src/xml/writer.rs @@ -169,7 +169,7 @@ impl PlistEventWriter for EventWriter { self.end_element("false")?; } PlistEvent::DataValue(ref value) => { - let base64_data = base64::encode_config(&value, base64::MIME); + let base64_data = base64::encode_config(&value, base64::STANDARD); self.write_element_and_value("data", &base64_data)?; } PlistEvent::DateValue(ref value) => { -- cgit v1.2.3