Skip to content

Commit 3d84b23

Browse files
authored
Merge pull request #638 from swimos/dependabot/cargo/base64-0.22
Update base64 requirement from 0.13 to 0.22
2 parents 2ae1bdd + 56a1c27 commit 3d84b23

File tree

6 files changed

+25
-41
lines changed

6 files changed

+25
-41
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ nom_locate = "4.0"
7676
tracing = "0.1"
7777
tracing-subscriber = "0.3"
7878
tracing-appender = "0.2"
79-
base64 = "0.13"
79+
base64 = "0.22"
8080
num-traits = "0.2"
8181
thiserror = "1.0"
8282
static_assertions = "1.1.0"

api/formats/swimos_recon/src/printer/mod.rs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
mod tests;
1717

1818
use base64::display::Base64Display;
19+
use base64::engine::general_purpose::STANDARD;
1920
use std::borrow::Cow;
2021
use std::fmt::{Debug, Display, Formatter};
2122
use swimos_form::write::{
@@ -224,34 +225,18 @@ where
224225
fn write_blob_vec(self, blob: Vec<u8>) -> Result<Self::Repr, Self::Error> {
225226
let StructurePrinter { fmt, has_attr, .. } = self;
226227
if has_attr {
227-
write!(
228-
fmt,
229-
" %{}",
230-
Base64Display::with_config(blob.as_slice(), base64::STANDARD)
231-
)
228+
write!(fmt, " %{}", Base64Display::new(blob.as_slice(), &STANDARD))
232229
} else {
233-
write!(
234-
fmt,
235-
"%{}",
236-
Base64Display::with_config(blob.as_slice(), base64::STANDARD)
237-
)
230+
write!(fmt, "%{}", Base64Display::new(blob.as_slice(), &STANDARD))
238231
}
239232
}
240233

241234
fn write_blob(self, value: &[u8]) -> Result<Self::Repr, Self::Error> {
242235
let StructurePrinter { fmt, has_attr, .. } = self;
243236
if has_attr {
244-
write!(
245-
fmt,
246-
" %{}",
247-
Base64Display::with_config(value, base64::STANDARD)
248-
)
237+
write!(fmt, " %{}", Base64Display::new(value, &STANDARD))
249238
} else {
250-
write!(
251-
fmt,
252-
"%{}",
253-
Base64Display::with_config(value, base64::STANDARD)
254-
)
239+
write!(fmt, "%{}", Base64Display::new(value, &STANDARD))
255240
}
256241
}
257242
}
@@ -612,7 +597,7 @@ where
612597
strategy,
613598
..
614599
} = self;
615-
let rep = Base64Display::with_config(blob.as_slice(), base64::STANDARD);
600+
let rep = Base64Display::new(blob.as_slice(), &STANDARD);
616601
if delegated {
617602
if has_attr {
618603
write!(fmt, " %{}{})", &rep, strategy.attr_body_padding())
@@ -638,7 +623,7 @@ where
638623
strategy,
639624
..
640625
} = self;
641-
let rep = Base64Display::with_config(value, base64::STANDARD);
626+
let rep = Base64Display::new(value, &STANDARD);
642627
if delegated {
643628
if has_attr {
644629
write!(fmt, " %{}{})", &rep, strategy.attr_body_padding())

api/formats/swimos_recon/src/recon_parser/tokens.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
use crate::parser::Span;
16+
use base64::{engine::general_purpose::STANDARD, Engine};
1617
use either::Either;
1718
use nom::branch::alt;
1819
use nom::combinator::{map, map_res, opt, peek, recognize};
@@ -333,7 +334,7 @@ macro_rules! token_mod {
333334
}
334335

335336
pub fn blob(input: Span<'_>) -> IResult<Span<'_>, Vec<u8>> {
336-
map_res(base64_literal, |span| base64::decode(*span))(input)
337+
map_res(base64_literal, |span| STANDARD.decode(*span))(input)
337338
}
338339

339340
pub fn comments(input: Span<'_>) -> IResult<Span<'_>, Vec<Span<'_>>> {

api/swimos_model/src/blob.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use base64::write::EncoderWriter;
16-
use base64::{DecodeError, URL_SAFE};
15+
use base64::{engine::general_purpose::URL_SAFE, write::EncoderWriter, DecodeError, Engine};
1716
use core::fmt;
1817
use std::borrow::{Borrow, BorrowMut};
1918
use std::fmt::{Display, Formatter};
@@ -41,17 +40,17 @@ impl Blob {
4140

4241
/// Attempts to encode this blob's data into the provided writer.
4342
pub fn encode_to_writer<W: Write>(&self, mut writer: W) -> io::Result<()> {
44-
EncoderWriter::new(&mut writer, URL_SAFE).write_all(&self.data)
43+
EncoderWriter::new(&mut writer, &URL_SAFE).write_all(&self.data)
4544
}
4645

4746
/// Consumes this BLOB and returns the decoded data.
4847
pub fn into_decoded(self) -> Result<Vec<u8>, DecodeError> {
49-
base64::decode_config(self.data, URL_SAFE)
48+
URL_SAFE.decode(self.data)
5049
}
5150

5251
/// Clone the underlying data and decode it.
5352
pub fn as_decoded(&self) -> Result<Vec<u8>, DecodeError> {
54-
base64::decode_config(self.data.clone(), URL_SAFE)
53+
URL_SAFE.decode(self.data.clone())
5554
}
5655

5756
/// Attempts to decode the provided data. Returning a result containing either the decoded data
@@ -60,12 +59,12 @@ impl Blob {
6059
where
6160
T: AsRef<[u8]>,
6261
{
63-
base64::decode_config(encoded.as_ref(), URL_SAFE).map(Blob::from_vec)
62+
URL_SAFE.decode(encoded).map(Blob::from_vec)
6463
}
6564

6665
/// Encodes the provided data into a [`Blob`].
6766
pub fn encode<T: AsRef<[u8]>>(input: T) -> Blob {
68-
let encoded = base64::encode_config(input, URL_SAFE);
67+
let encoded = URL_SAFE.encode(input);
6968
Blob {
7069
data: Vec::from(encoded.as_bytes()),
7170
}
@@ -114,8 +113,8 @@ mod tests {
114113

115114
#[test]
116115
fn from_encoded() {
117-
let encoded = base64::encode_config("swimming", URL_SAFE);
118-
let decoded = base64::decode_config(encoded.as_bytes(), URL_SAFE).unwrap();
116+
let encoded = URL_SAFE.encode("swimming");
117+
let decoded = URL_SAFE.decode(encoded.as_bytes()).unwrap();
119118
let blob = Blob::from_encoded(Vec::from(encoded.as_bytes()));
120119

121120
assert_eq!(decoded, blob.into_decoded().unwrap())

runtime/swimos_http/src/websocket.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
use std::{
2-
collections::HashSet,
3-
pin::Pin,
4-
task::{Context, Poll},
5-
};
6-
1+
use base64::{engine::general_purpose::STANDARD, Engine};
72
use bytes::{Bytes, BytesMut};
83
use futures::{ready, Future, FutureExt};
94
use http::{header::HeaderName, HeaderMap, HeaderValue, Method};
@@ -17,6 +12,11 @@ use ratchet::{
1712
WebSocketStream,
1813
};
1914
use sha1::{Digest, Sha1};
15+
use std::{
16+
collections::HashSet,
17+
pin::Pin,
18+
task::{Context, Poll},
19+
};
2020
use thiserror::Error;
2121

2222
const UPGRADE_STR: &str = "Upgrade";
@@ -125,7 +125,7 @@ where
125125
Digest::update(&mut digest, key);
126126
Digest::update(&mut digest, ACCEPT_KEY);
127127

128-
let sec_websocket_accept = base64::encode(digest.finalize());
128+
let sec_websocket_accept = STANDARD.encode(digest.finalize());
129129
let mut builder = Response::builder()
130130
.status(http::StatusCode::SWITCHING_PROTOCOLS)
131131
.header(http::header::SEC_WEBSOCKET_ACCEPT, sec_websocket_accept)

server/swimos_server_app/src/server/http/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ impl Listener<DuplexStream> for TestListener {
119119
}
120120

121121
async fn run_server(rx: mpsc::Receiver<DuplexStream>, find_tx: mpsc::Sender<FindNode>) {
122-
println!("Server start");
123122
let listener = TestListener { rx };
124123

125124
let config = HttpConfig {

0 commit comments

Comments
 (0)