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