Skip to content

Commit

Permalink
Upgrade the base64 dependency to 0.21. (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubadamw authored Mar 14, 2023
1 parent 15cb998 commit dbead9a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ hyperx = "1.3.0"
snafu = { version = "0.7", features = ["backtraces"] }
once_cell = "1.7.2"
arc-swap = "1.3.0"
base64 = "0.20.0"
base64 = "0.21.0"
bytes = "1.0.1"
jsonwebtoken = "8"
futures-core = { version = "0.3.15", optional = true }
Expand Down
6 changes: 4 additions & 2 deletions src/api/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,12 @@ impl<'octo> RepoHandler<'octo> {
message: impl Into<String>,
content: impl AsRef<[u8]>,
) -> UpdateFileBuilder<'_, '_> {
use base64::Engine;
UpdateFileBuilder::new(
self,
path.into(),
message.into(),
base64::encode(content),
base64::prelude::BASE64_STANDARD.encode(content),
None,
)
}
Expand Down Expand Up @@ -284,11 +285,12 @@ impl<'octo> RepoHandler<'octo> {
content: impl AsRef<[u8]>,
sha: impl Into<String>,
) -> UpdateFileBuilder<'_, '_> {
use base64::Engine;
UpdateFileBuilder::new(
self,
path.into(),
message.into(),
base64::encode(content),
base64::prelude::BASE64_STANDARD.encode(content),
Some(sha.into()),
)
}
Expand Down
5 changes: 1 addition & 4 deletions src/models/events/payload/pull_request_review.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use crate::models::{
pulls::{PullRequest, Review},
Repository, User,
};
use crate::models::pulls::{PullRequest, Review};
use serde::{Deserialize, Serialize};

/// The payload in a [`super::EventPayload::PullRequestReviewEvent`] type.
Expand Down
3 changes: 2 additions & 1 deletion src/models/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ impl Content {
/// # }
/// ```
pub fn decoded_content(&self) -> Option<String> {
use base64::Engine;
self.content.as_ref().and_then(|c| {
let mut content = c.as_bytes().to_owned();
content.retain(|b| !b" \n\t\r\x0b\x0c".contains(b));
let c = base64::decode(&content).unwrap();
let c = base64::prelude::BASE64_STANDARD.decode(content).unwrap();
Some(String::from_utf8_lossy(&c).into_owned())
})
}
Expand Down

0 comments on commit dbead9a

Please sign in to comment.