mirror of
https://github.com/wez/wezterm.git
synced 2024-11-26 08:25:50 +03:00
update base64, work around another batch of breaking API changes
closes: https://github.com/wez/wezterm/pull/2931
This commit is contained in:
parent
c9a0537b7b
commit
d34297cd2c
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -294,9 +294,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.20.0"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5"
|
||||
checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a"
|
||||
|
||||
[[package]]
|
||||
name = "base91"
|
||||
@ -2304,9 +2304,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ipnet"
|
||||
version = "2.7.0"
|
||||
version = "2.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11b0d96e660696543b251e58030cf9787df56da39dab19ad60eae7353040917e"
|
||||
checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146"
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
@ -2906,7 +2906,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"base64 0.20.0",
|
||||
"base64 0.21.0",
|
||||
"bintree",
|
||||
"bitflags",
|
||||
"chrono",
|
||||
@ -4993,7 +4993,7 @@ name = "termwiz"
|
||||
version = "0.19.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.20.0",
|
||||
"base64 0.21.0",
|
||||
"bitflags",
|
||||
"cassowary",
|
||||
"criterion",
|
||||
@ -6048,7 +6048,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"assert_fs",
|
||||
"async_ossl",
|
||||
"base64 0.20.0",
|
||||
"base64 0.21.0",
|
||||
"bitflags",
|
||||
"camino",
|
||||
"clap 4.0.32",
|
||||
|
@ -9,7 +9,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
async-trait = "0.1"
|
||||
base64 = "0.20"
|
||||
base64 = "0.21"
|
||||
bintree = { path = "../bintree" }
|
||||
bitflags = "1.3"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
|
@ -12,7 +12,7 @@ readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
# backtrace = "0.3"
|
||||
base64 = "0.20"
|
||||
base64 = "0.21"
|
||||
bitflags = "1.3"
|
||||
cassowary = {version="0.3", optional=true}
|
||||
anyhow = "1.0"
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::escape::osc::{base64_decode, base64_encode};
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::{Display, Error as FmtError, Formatter};
|
||||
use std::io::{Read, Seek};
|
||||
@ -112,17 +113,17 @@ impl KittyImageData {
|
||||
match t {
|
||||
"d" => Some(Self::Direct(String::from_utf8(payload.to_vec()).ok()?)),
|
||||
"f" => Some(Self::File {
|
||||
path: String::from_utf8(base64::decode(payload.to_vec()).ok()?).ok()?,
|
||||
path: String::from_utf8(base64_decode(payload.to_vec()).ok()?).ok()?,
|
||||
data_size: geti(keys, "S"),
|
||||
data_offset: geti(keys, "O"),
|
||||
}),
|
||||
"t" => Some(Self::TemporaryFile {
|
||||
path: String::from_utf8(base64::decode(payload.to_vec()).ok()?).ok()?,
|
||||
path: String::from_utf8(base64_decode(payload.to_vec()).ok()?).ok()?,
|
||||
data_size: geti(keys, "S"),
|
||||
data_offset: geti(keys, "O"),
|
||||
}),
|
||||
"s" => Some(Self::SharedMem {
|
||||
name: String::from_utf8(base64::decode(payload.to_vec()).ok()?).ok()?,
|
||||
name: String::from_utf8(base64_decode(payload.to_vec()).ok()?).ok()?,
|
||||
data_size: geti(keys, "S"),
|
||||
data_offset: geti(keys, "O"),
|
||||
}),
|
||||
@ -141,7 +142,7 @@ impl KittyImageData {
|
||||
data_size,
|
||||
} => {
|
||||
keys.insert("t", "f".to_string());
|
||||
keys.insert("payload", base64::encode(&path));
|
||||
keys.insert("payload", base64_encode(&path));
|
||||
set(keys, "S", data_size);
|
||||
set(keys, "S", data_offset);
|
||||
}
|
||||
@ -151,7 +152,7 @@ impl KittyImageData {
|
||||
data_size,
|
||||
} => {
|
||||
keys.insert("t", "t".to_string());
|
||||
keys.insert("payload", base64::encode(&path));
|
||||
keys.insert("payload", base64_encode(&path));
|
||||
set(keys, "S", data_size);
|
||||
set(keys, "S", data_offset);
|
||||
}
|
||||
@ -161,7 +162,7 @@ impl KittyImageData {
|
||||
data_size,
|
||||
} => {
|
||||
keys.insert("t", "s".to_string());
|
||||
keys.insert("payload", base64::encode(&name));
|
||||
keys.insert("payload", base64_encode(&name));
|
||||
set(keys, "S", data_size);
|
||||
set(keys, "S", data_offset);
|
||||
}
|
||||
@ -195,7 +196,7 @@ impl KittyImageData {
|
||||
|
||||
match self {
|
||||
Self::Direct(data) => {
|
||||
base64::decode(data).or_else(|_| Err(std::io::ErrorKind::InvalidInput.into()))
|
||||
base64_decode(data).or_else(|_| Err(std::io::ErrorKind::InvalidInput.into()))
|
||||
}
|
||||
Self::File {
|
||||
path,
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::color::SrgbaTuple;
|
||||
pub use crate::hyperlink::Hyperlink;
|
||||
use crate::{bail, ensure, Result};
|
||||
use base64::Engine;
|
||||
use bitflags::bitflags;
|
||||
use num_derive::*;
|
||||
use num_traits::FromPrimitive;
|
||||
@ -168,7 +169,7 @@ impl OperatingSystemCommand {
|
||||
Selection::try_parse(osc[1]).map(OperatingSystemCommand::QuerySelection)
|
||||
} else if osc.len() == 3 {
|
||||
let sel = Selection::try_parse(osc[1])?;
|
||||
let bytes = base64::decode(osc[2])?;
|
||||
let bytes = base64_decode(osc[2])?;
|
||||
let s = String::from_utf8(bytes)?;
|
||||
Ok(OperatingSystemCommand::SetSelection(sel, s))
|
||||
} else {
|
||||
@ -505,7 +506,7 @@ impl Display for OperatingSystemCommand {
|
||||
}
|
||||
ClearSelection(s) => write!(f, "52;{}", s)?,
|
||||
QuerySelection(s) => write!(f, "52;{};?", s)?,
|
||||
SetSelection(s, val) => write!(f, "52;{};{}", s, base64::encode(val))?,
|
||||
SetSelection(s, val) => write!(f, "52;{};{}", s, base64_encode(val))?,
|
||||
SystemNotification(s) => write!(f, "9;{}", s)?,
|
||||
ITermProprietary(i) => i.fmt(f)?,
|
||||
FinalTermSemanticPrompt(i) => i.fmt(f)?,
|
||||
@ -907,7 +908,7 @@ impl ITermFileData {
|
||||
let param = if idx == last {
|
||||
// The final argument contains `:base64`, so look for that
|
||||
if let Some(colon) = param.iter().position(|c| *c == b':') {
|
||||
data = Some(base64::decode(¶m[colon + 1..])?);
|
||||
data = Some(base64_decode(¶m[colon + 1..])?);
|
||||
¶m[..colon]
|
||||
} else {
|
||||
// If we don't find the colon in the last piece, we've
|
||||
@ -935,7 +936,7 @@ impl ITermFileData {
|
||||
|
||||
let name = params
|
||||
.get("name")
|
||||
.and_then(|s| base64::decode(s).ok())
|
||||
.and_then(|s| base64_decode(s).ok())
|
||||
.and_then(|b| String::from_utf8(b).ok());
|
||||
let size = params.get("size").and_then(|s| s.parse().ok());
|
||||
let width = params
|
||||
@ -983,7 +984,7 @@ impl Display for ITermFileData {
|
||||
}
|
||||
if let Some(ref name) = self.name {
|
||||
sep = emit_sep(sep, f)?;
|
||||
write!(f, "name={}", base64::encode(name))?;
|
||||
write!(f, "name={}", base64_encode(name))?;
|
||||
}
|
||||
if self.width != ITermDimension::Automatic {
|
||||
sep = emit_sep(sep, f)?;
|
||||
@ -1010,7 +1011,7 @@ impl Display for ITermFileData {
|
||||
if sep == "=" {
|
||||
write!(f, "=")?;
|
||||
}
|
||||
write!(f, ":{}", base64::encode(&self.data))?;
|
||||
write!(f, ":{}", base64_encode(&self.data))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@ -1145,13 +1146,13 @@ impl ITermProprietary {
|
||||
};
|
||||
|
||||
if osc.len() == 3 && keyword == "Copy" && p1_empty {
|
||||
return Ok(ITermProprietary::Copy(String::from_utf8(base64::decode(
|
||||
return Ok(ITermProprietary::Copy(String::from_utf8(base64_decode(
|
||||
osc[2],
|
||||
)?)?));
|
||||
}
|
||||
if osc.len() == 3 && keyword == "SetBadgeFormat" && p1_empty {
|
||||
return Ok(ITermProprietary::SetBadgeFormat(String::from_utf8(
|
||||
base64::decode(osc[2])?,
|
||||
base64_decode(osc[2])?,
|
||||
)?));
|
||||
}
|
||||
|
||||
@ -1183,7 +1184,7 @@ impl ITermProprietary {
|
||||
if let (Some(k), Some(v)) = (p1, p2) {
|
||||
return Ok(ITermProprietary::SetUserVar {
|
||||
name: k.to_string(),
|
||||
value: String::from_utf8(base64::decode(v)?)?,
|
||||
value: String::from_utf8(base64_decode(v)?)?,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1222,6 +1223,18 @@ impl ITermProprietary {
|
||||
}
|
||||
}
|
||||
|
||||
/// base64::encode is deprecated, so make a less frustrating helper
|
||||
pub(crate) fn base64_encode<T: AsRef<[u8]>>(s: T) -> String {
|
||||
base64::engine::general_purpose::STANDARD.encode(s)
|
||||
}
|
||||
|
||||
/// base64::decode is deprecated, so make a less frustrating helper
|
||||
pub(crate) fn base64_decode<T: AsRef<[u8]>>(
|
||||
s: T,
|
||||
) -> std::result::Result<Vec<u8>, base64::DecodeError> {
|
||||
base64::engine::general_purpose::STANDARD.decode(s)
|
||||
}
|
||||
|
||||
impl Display for ITermProprietary {
|
||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
||||
write!(f, "1337;")?;
|
||||
@ -1251,12 +1264,12 @@ impl Display for ITermProprietary {
|
||||
f,
|
||||
"ReportCellSize={height_pixels:.1};{width_pixels:.1};{scale:.1}",
|
||||
)?,
|
||||
Copy(s) => write!(f, "Copy=;{}", base64::encode(s))?,
|
||||
ReportVariable(s) => write!(f, "ReportVariable={}", base64::encode(s))?,
|
||||
Copy(s) => write!(f, "Copy=;{}", base64_encode(s))?,
|
||||
ReportVariable(s) => write!(f, "ReportVariable={}", base64_encode(s))?,
|
||||
SetUserVar { name, value } => {
|
||||
write!(f, "SetUserVar={}={}", name, base64::encode(value))?
|
||||
write!(f, "SetUserVar={}={}", name, base64_encode(value))?
|
||||
}
|
||||
SetBadgeFormat(s) => write!(f, "SetBadgeFormat={}", base64::encode(s))?,
|
||||
SetBadgeFormat(s) => write!(f, "SetBadgeFormat={}", base64_encode(s))?,
|
||||
File(file) => file.fmt(f)?,
|
||||
UnicodeVersion(ITermUnicodeVersionOp::Set(n)) => write!(f, "UnicodeVersion={}", n)?,
|
||||
UnicodeVersion(ITermUnicodeVersionOp::Push(Some(label))) => {
|
||||
|
@ -18,7 +18,7 @@ vendored-openssl-libssh-rs = ["libssh-rs/vendored-openssl"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
base64 = "0.20"
|
||||
base64 = "0.21"
|
||||
bitflags = "1.3"
|
||||
camino = "1.0"
|
||||
dirs-next = "2.0"
|
||||
|
@ -115,11 +115,12 @@ impl crate::sessioninner::SessionInner {
|
||||
let fingerprint = sess
|
||||
.host_key_hash(ssh2::HashType::Sha256)
|
||||
.map(|fingerprint| {
|
||||
let engine = base64::engine::fast_portable::FastPortable::from(
|
||||
use base64::Engine;
|
||||
let engine = base64::engine::general_purpose::GeneralPurpose::new(
|
||||
&base64::alphabet::STANDARD,
|
||||
base64::engine::fast_portable::NO_PAD,
|
||||
base64::engine::general_purpose::NO_PAD,
|
||||
);
|
||||
format!("SHA256:{}", base64::encode_engine(fingerprint, &engine))
|
||||
format!("SHA256:{}", engine.encode(fingerprint))
|
||||
})
|
||||
.or_else(|| {
|
||||
// Querying for the Sha256 can fail if for example we were linked
|
||||
|
Loading…
Reference in New Issue
Block a user