Update base64 0.20.0 => 0.21.0

This commit is contained in:
jcamiel 2023-01-09 13:15:41 +01:00
parent 458c780238
commit 3917c4ac55
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
7 changed files with 30 additions and 24 deletions

4
Cargo.lock generated
View File

@ -60,9 +60,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[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 = "bit-set"

View File

@ -18,7 +18,7 @@ strict = []
[dependencies]
atty = "0.2.14"
base64 = "0.20.0"
base64 = "0.21.0"
brotli = "3.3.4"
chrono = { version = "0.4.23", default-features = false, features = ["clock"] }
clap = { version = "4.0.32", features = ["cargo", "string", "wrap_help"] }

View File

@ -31,6 +31,8 @@ use super::response::*;
use super::{Header, HttpError, Verbosity};
use crate::cli::Logger;
use crate::http::ContextDir;
use base64::engine::general_purpose;
use base64::Engine;
use curl::easy::List;
use std::str::FromStr;
use url::Url;
@ -423,7 +425,8 @@ impl Client {
}
if let Some(ref user) = options.user {
let authorization = base64::encode(user.as_bytes());
let user = user.as_bytes();
let authorization = general_purpose::STANDARD.encode(user);
if request.get_header_values("Authorization").is_empty() {
list.append(format!("Authorization: Basic {}", authorization).as_str())
.unwrap();

View File

@ -17,6 +17,8 @@
*/
use crate::runner::Value;
use base64::engine::general_purpose;
use base64::Engine;
impl Value {
pub fn to_json(&self) -> serde_json::Value {
@ -47,7 +49,7 @@ impl Value {
serde_json::Value::Object(map)
}
Value::Bytes(v) => {
let encoded = base64::encode(v);
let encoded = general_purpose::STANDARD.encode(v);
serde_json::Value::String(encoded)
}
Value::Null => serde_json::Value::Null,

View File

@ -16,6 +16,8 @@
*
*/
use base64::engine::general_purpose;
use base64::Engine;
use std::collections::HashMap;
#[allow(unused)]
use std::io::prelude::*;
@ -52,8 +54,8 @@ pub fn eval_request(
if let Some(kv) = &request.basic_auth() {
let value = eval_template(&kv.value, variables)?;
let user_password = format!("{}:{}", kv.key.value, value);
let authorization = base64::encode(user_password.as_bytes());
let user_password = user_password.as_bytes();
let authorization = general_purpose::STANDARD.encode(user_password);
let name = "Authorization".to_string();
let value = format!("Basic {}", authorization);
let header = http::Header { name, value };

View File

@ -15,7 +15,7 @@ strict = []
[dependencies]
atty = "0.2.14"
base64 = "0.20.0"
base64 = "0.21.0"
clap = { version = "4.0.32", features = ["cargo", "wrap_help"] }
colored = "2.0.0"
hurl_core = { version = "2.0.0-SNAPSHOT", path = "../hurl_core" }

View File

@ -16,6 +16,9 @@
*
*/
use base64::engine::general_purpose;
use base64::Engine;
use hurl_core::ast::*;
use super::serialize_json::*;
@ -179,24 +182,20 @@ impl ToJson for Bytes {
impl ToJson for Base64 {
fn to_json(&self) -> JValue {
let value = general_purpose::STANDARD.encode(&self.value);
JValue::Object(vec![
("encoding".to_string(), JValue::String("base64".to_string())),
(
"value".to_string(),
JValue::String(base64::encode(&self.value)),
),
("value".to_string(), JValue::String(value)),
])
}
}
impl ToJson for Hex {
fn to_json(&self) -> JValue {
let value = general_purpose::STANDARD.encode(&self.value);
JValue::Object(vec![
("encoding".to_string(), JValue::String("base64".to_string())),
(
"value".to_string(),
JValue::String(base64::encode(&self.value)),
),
("value".to_string(), JValue::String(value)),
])
}
}
@ -475,14 +474,14 @@ fn json_predicate_value(predicate_value: PredicateValue) -> (JValue, Option<Stri
PredicateValue::Float(value) => (JValue::Number(value.to_string()), None),
PredicateValue::Bool(value) => (JValue::Boolean(value), None),
PredicateValue::Null {} => (JValue::Null, None),
PredicateValue::Hex(value) => (
JValue::String(base64::encode(value.value)),
Some("base64".to_string()),
),
PredicateValue::Base64(value) => (
JValue::String(base64::encode(value.value)),
Some("base64".to_string()),
),
PredicateValue::Hex(value) => {
let base64_string = general_purpose::STANDARD.encode(value.value);
(JValue::String(base64_string), Some("base64".to_string()))
}
PredicateValue::Base64(value) => {
let base64_string = general_purpose::STANDARD.encode(value.value);
(JValue::String(base64_string), Some("base64".to_string()))
}
PredicateValue::Expression(value) => (JValue::String(value.to_string()), None),
PredicateValue::Regex(value) => {
(JValue::String(value.to_string()), Some("regex".to_string()))