mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
Update to base64 0.21
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -889,7 +889,7 @@ dependencies = [
|
||||
"async-smtp",
|
||||
"async_zip",
|
||||
"backtrace",
|
||||
"base64 0.20.0",
|
||||
"base64 0.21.0",
|
||||
"bitflags",
|
||||
"chrono",
|
||||
"criterion",
|
||||
|
||||
@@ -37,7 +37,7 @@ trust-dns-resolver = "0.22"
|
||||
tokio = { version = "1", features = ["fs", "rt-multi-thread", "macros"] }
|
||||
tokio-tar = { version = "0.3" } # TODO: integrate tokio into async-tar
|
||||
backtrace = "0.3"
|
||||
base64 = "0.20"
|
||||
base64 = "0.21"
|
||||
bitflags = "1.3"
|
||||
chrono = { version = "0.4", default-features=false, features = ["clock", "std"] }
|
||||
dirs = { version = "4", optional=true }
|
||||
|
||||
@@ -11,6 +11,7 @@ use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
|
||||
use anyhow::{Context as _, Result};
|
||||
use base64::Engine as _;
|
||||
use futures::future::FutureExt;
|
||||
use lettre_email::mime::{self, Mime};
|
||||
use lettre_email::PartBuilder;
|
||||
@@ -234,7 +235,7 @@ impl HtmlMsgParser {
|
||||
/// Convert a mime part to a data: url as defined in [RFC 2397](https://tools.ietf.org/html/rfc2397).
|
||||
fn mimepart_to_data_url(mail: &mailparse::ParsedMail<'_>) -> Result<String> {
|
||||
let data = mail.get_body_raw()?;
|
||||
let data = base64::encode(data);
|
||||
let data = base64::engine::general_purpose::STANDARD.encode(data);
|
||||
Ok(format!("data:{};base64,{}", mail.ctype.mimetype, data))
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use std::io::Cursor;
|
||||
use std::pin::Pin;
|
||||
|
||||
use anyhow::{ensure, Context as _, Result};
|
||||
use base64::Engine as _;
|
||||
use futures::Future;
|
||||
use num_traits::FromPrimitive;
|
||||
use pgp::composed::Deserializable;
|
||||
@@ -36,7 +37,7 @@ pub trait DcKey: Serialize + Deserializable + KeyTrait + Clone {
|
||||
fn from_base64(data: &str) -> Result<Self> {
|
||||
// strip newlines and other whitespace
|
||||
let cleaned: String = data.split_whitespace().collect();
|
||||
let bytes = base64::decode(cleaned.as_bytes())?;
|
||||
let bytes = base64::engine::general_purpose::STANDARD.decode(cleaned.as_bytes())?;
|
||||
Self::from_slice(&bytes)
|
||||
}
|
||||
|
||||
@@ -67,7 +68,7 @@ pub trait DcKey: Serialize + Deserializable + KeyTrait + Clone {
|
||||
|
||||
/// Serialise the key to a base64 string.
|
||||
fn to_base64(&self) -> String {
|
||||
base64::encode(DcKey::to_bytes(self))
|
||||
base64::engine::general_purpose::STANDARD.encode(DcKey::to_bytes(self))
|
||||
}
|
||||
|
||||
/// Serialise the key to ASCII-armored representation.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use std::convert::TryInto;
|
||||
|
||||
use anyhow::{bail, ensure, Context as _, Result};
|
||||
use base64::Engine as _;
|
||||
use chrono::TimeZone;
|
||||
use format_flowed::{format_flowed, format_flowed_quote};
|
||||
use lettre_email::{mime, Address, Header, MimeMultipartType, PartBuilder};
|
||||
@@ -1341,7 +1342,7 @@ impl<'a> MimeFactory<'a> {
|
||||
/// This line length limit is an
|
||||
/// [RFC5322 requirement](https://tools.ietf.org/html/rfc5322#section-2.1.1).
|
||||
fn wrapped_base64_encode(buf: &[u8]) -> String {
|
||||
let base64 = base64::encode(buf);
|
||||
let base64 = base64::engine::general_purpose::STANDARD.encode(buf);
|
||||
let mut chars = base64.chars();
|
||||
std::iter::repeat_with(|| chars.by_ref().take(78).collect::<String>())
|
||||
.take_while(|s| !s.is_empty())
|
||||
|
||||
@@ -8,6 +8,7 @@ use std::pin::Pin;
|
||||
use std::str;
|
||||
|
||||
use anyhow::{bail, Context as _, Result};
|
||||
use base64::Engine as _;
|
||||
use deltachat_derive::{FromSql, ToSql};
|
||||
use format_flowed::unformat_flowed;
|
||||
use lettre_email::mime::{self, Mime};
|
||||
@@ -663,7 +664,7 @@ impl MimeMessage {
|
||||
.split_ascii_whitespace()
|
||||
.collect::<String>()
|
||||
.strip_prefix("base64:")
|
||||
.map(base64::decode)
|
||||
.map(|x| base64::engine::general_purpose::STANDARD.decode(x))
|
||||
{
|
||||
// Avatar sent directly in the header as base64.
|
||||
if let Ok(decoded_data) = avatar {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use anyhow::Result;
|
||||
use base64::Engine as _;
|
||||
use qrcodegen::{QrCode, QrCodeEcc};
|
||||
|
||||
use crate::{
|
||||
@@ -211,7 +212,10 @@ fn inner_generate_secure_join_qr_code(
|
||||
d.attr("clip-path", "url(#avatar-cut)")?;
|
||||
d.attr(
|
||||
"href", /*might need xlink:href instead if it doesn't work on older devices?*/
|
||||
format!("data:image/jpeg;base64,{}", base64::encode(img)),
|
||||
format!(
|
||||
"data:image/jpeg;base64,{}",
|
||||
base64::engine::general_purpose::STANDARD.encode(img)
|
||||
),
|
||||
)
|
||||
})?;
|
||||
} else {
|
||||
|
||||
10
src/tools.rs
10
src/tools.rs
@@ -12,6 +12,7 @@ use std::str::from_utf8;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use anyhow::{bail, Context as _, Result};
|
||||
use base64::Engine as _;
|
||||
use chrono::{Local, TimeZone};
|
||||
use futures::{StreamExt, TryStreamExt};
|
||||
use mailparse::dateparse;
|
||||
@@ -276,12 +277,6 @@ async fn maybe_warn_on_outdated(context: &Context, now: i64, approx_compile_time
|
||||
/// - for INCOMING messages, the ID is taken from the Chat-Group-ID-header or from the Message-ID in the In-Reply-To: or References:-Header
|
||||
/// - the group-id should be a string with the characters [a-zA-Z0-9\-_]
|
||||
pub(crate) fn create_id() -> String {
|
||||
const URL_SAFE_ENGINE: base64::engine::fast_portable::FastPortable =
|
||||
base64::engine::fast_portable::FastPortable::from(
|
||||
&base64::alphabet::URL_SAFE,
|
||||
base64::engine::fast_portable::NO_PAD,
|
||||
);
|
||||
|
||||
// ThreadRng implements CryptoRng trait and is supposed to be cryptographically secure.
|
||||
let mut rng = thread_rng();
|
||||
|
||||
@@ -290,7 +285,8 @@ pub(crate) fn create_id() -> String {
|
||||
rng.fill(&mut arr[..]);
|
||||
|
||||
// Take 11 base64 characters containing 66 random bits.
|
||||
base64::encode_engine(arr, &URL_SAFE_ENGINE)
|
||||
base64::engine::general_purpose::URL_SAFE
|
||||
.encode(arr)
|
||||
.chars()
|
||||
.take(11)
|
||||
.collect()
|
||||
|
||||
Reference in New Issue
Block a user