diff options
| author | Teddy Wing | 2018-11-07 19:45:51 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2018-11-07 20:11:25 +0100 | 
| commit | 497a6e3977c9a5fe1a25103b7133885f81d2b452 (patch) | |
| tree | a2a1dc7425e32d39a601477f3cb0304ccca5b48d | |
| parent | ce37d818a79f2da21b5e14554af3b09b32b7e020 (diff) | |
| download | rust-plist-497a6e3977c9a5fe1a25103b7133885f81d2b452.tar.bz2 | |
EventReader,PlistEventWriter: Change use `base64::STANDARD` for `Data`data-without-base64-mime
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.
| -rw-r--r-- | src/xml/reader.rs | 2 | ||||
| -rw-r--r-- | src/xml/writer.rs | 2 | 
2 files changed, 2 insertions, 2 deletions
| 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<R: Read> EventReader<R> {                          "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<W: Write> PlistEventWriter for EventWriter<W> {                  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) => { | 
