Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump base64 to v0.21 #433

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix issue [#423](https://github.com/ron-rs/ron/issues/423) deserialising an identifier into a borrowed str ([#424](https://github.com/ron-rs/ron/pull/424))
- Add `escape_strings` option to `PrettyConfig` to allow serialising with or without escaping ([#426](https://github.com/ron-rs/ron/pull/426))
- Bump MSRV to 1.57.0 and bump dependency: `base64` to 0.20 ([#431](https://github.com/ron-rs/ron/pull/431))
- Bump dependency `base64` to 0.21 ([#433](https://github.com/ron-rs/ron/pull/433))

## [0.8.0] - 2022-08-17

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ default = []
integer128 = []

[dependencies]
base64 = "0.20"
base64 = "0.21"
bitflags = "1.3"
indexmap = { version = "1.9", features = ["serde-1"], optional = true }
# serde supports i128/u128 from 1.0.60 onwards
Expand Down
5 changes: 3 additions & 2 deletions src/de/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// Deserialization module.
use std::{borrow::Cow, io, str};

use base64::Engine;
use serde::de::{self, DeserializeSeed, Deserializer as SerdeError, Visitor};

use self::{id::IdDeserializer, tag::TagDeserializer};
Expand All @@ -9,7 +10,7 @@ use crate::{
error::{Result, SpannedResult},
extensions::Extensions,
options::Options,
parse::{AnyNum, Bytes, ParsedStr},
parse::{AnyNum, Bytes, ParsedStr, BASE64_ENGINE},
};

mod id;
Expand Down Expand Up @@ -403,7 +404,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
ParsedStr::Allocated(ref s) => s.as_str(),
ParsedStr::Slice(s) => s,
};
base64::decode(base64_str)
BASE64_ENGINE.decode(base64_str)
};

match res {
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{error::Error as StdError, fmt, io, str::Utf8Error, string::FromUtf8Err

use serde::{de, ser};

use crate::parse::{is_ident_first_char, is_ident_other_char, is_ident_raw_char};
use crate::parse::{is_ident_first_char, is_ident_other_char, is_ident_raw_char, BASE64_ENGINE};

/// This type represents all possible errors that can occur when
/// serializing or deserializing RON data.
Expand Down Expand Up @@ -303,7 +303,7 @@ impl de::Error for Error {
Char(c) => write!(f, "the UTF-8 character `{}`", c),
Str(s) => write!(f, "the string {:?}", s),
Bytes(b) => write!(f, "the bytes \"{}\"", {
base64::display::Base64Display::from(b, &base64::engine::DEFAULT_ENGINE)
base64::display::Base64Display::new(b, &BASE64_ENGINE)
}),
Unit => write!(f, "a unit value"),
Option => write!(f, "an optional value"),
Expand Down
4 changes: 4 additions & 0 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ use std::{
str::{from_utf8, from_utf8_unchecked, FromStr},
};

use base64::engine::general_purpose::{GeneralPurpose, STANDARD};

use crate::{
error::{Error, Position, Result, SpannedError, SpannedResult},
extensions::Extensions,
};

pub const BASE64_ENGINE: GeneralPurpose = STANDARD;

// We have the following char categories.
const INT_CHAR: u8 = 1 << 0; // [0-9A-Fa-f_]
const FLOAT_CHAR: u8 = 1 << 1; // [0-9\.Ee+-_]
Expand Down
8 changes: 6 additions & 2 deletions src/ser/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use std::io;

use base64::Engine;
use serde::{ser, Deserialize, Serialize};

use crate::{
error::{Error, Result},
extensions::Extensions,
options::Options,
parse::{is_ident_first_char, is_ident_other_char, is_ident_raw_char, LargeSInt, LargeUInt},
parse::{
is_ident_first_char, is_ident_other_char, is_ident_raw_char, LargeSInt, LargeUInt,
BASE64_ENGINE,
},
};

mod raw;
Expand Down Expand Up @@ -566,7 +570,7 @@ impl<'a, W: io::Write> ser::Serializer for &'a mut Serializer<W> {
}

fn serialize_bytes(self, v: &[u8]) -> Result<()> {
self.serialize_str(base64::encode(v).as_str())
self.serialize_str(BASE64_ENGINE.encode(v).as_str())
}

fn serialize_none(self) -> Result<()> {
Expand Down