mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 22:47:43 +02:00
update base64 implementation to newer crate (#7739)
# Description This PR updates the base64 crate, which has changed significantly, so all the base64 implementations had to be changed too. Tests pass. I hope that's enough. # User-Facing Changes None, except added a new character encoding imap-mutf7 as mutf7. # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
@ -1,19 +1,16 @@
|
||||
use base64::encode;
|
||||
use base64::{alphabet, engine::general_purpose::PAD, engine::GeneralPurpose, Engine};
|
||||
use nu_engine::CallExt;
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::util::BufferedReader;
|
||||
use nu_protocol::RawStream;
|
||||
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value,
|
||||
};
|
||||
use reqwest::blocking::Response;
|
||||
|
||||
use reqwest::StatusCode;
|
||||
use std::collections::HashMap;
|
||||
use std::io::BufReader;
|
||||
|
||||
use reqwest::StatusCode;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
@ -165,10 +162,24 @@ fn helper(
|
||||
let timeout = args.timeout;
|
||||
let headers = args.headers;
|
||||
let raw = args.raw;
|
||||
let base64_engine = GeneralPurpose::new(&alphabet::STANDARD, PAD);
|
||||
|
||||
let login = match (user, password) {
|
||||
(Some(user), Some(password)) => Some(encode(format!("{}:{}", user, password))),
|
||||
(Some(user), _) => Some(encode(format!("{}:", user))),
|
||||
(_, Some(password)) => Some(encode(format!(":{}", password))),
|
||||
(Some(user), Some(password)) => {
|
||||
let mut enc_str = String::new();
|
||||
base64_engine.encode_string(&format!("{}:{}", user, password), &mut enc_str);
|
||||
Some(enc_str)
|
||||
}
|
||||
(Some(user), _) => {
|
||||
let mut enc_str = String::new();
|
||||
base64_engine.encode_string(&format!("{}:", user), &mut enc_str);
|
||||
Some(enc_str)
|
||||
}
|
||||
(_, Some(password)) => {
|
||||
let mut enc_str = String::new();
|
||||
base64_engine.encode_string(&format!(":{}", password), &mut enc_str);
|
||||
Some(enc_str)
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
@ -1,19 +1,18 @@
|
||||
use crate::formats::value_to_json_value;
|
||||
use base64::encode;
|
||||
use base64::{alphabet, engine::general_purpose::PAD, engine::GeneralPurpose, Engine};
|
||||
use nu_engine::CallExt;
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::util::BufferedReader;
|
||||
use nu_protocol::RawStream;
|
||||
use reqwest::{blocking::Response, StatusCode};
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value,
|
||||
};
|
||||
use reqwest::{blocking::Response, StatusCode};
|
||||
use std::collections::HashMap;
|
||||
use std::io::BufReader;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
@ -186,9 +185,19 @@ fn helper(
|
||||
let headers = args.headers;
|
||||
let location = url;
|
||||
let raw = args.raw;
|
||||
let base64_engine = GeneralPurpose::new(&alphabet::STANDARD, PAD);
|
||||
|
||||
let login = match (user, password) {
|
||||
(Some(user), Some(password)) => Some(encode(&format!("{}:{}", user, password))),
|
||||
(Some(user), _) => Some(encode(&format!("{}:", user))),
|
||||
(Some(user), Some(password)) => {
|
||||
let mut enc_str = String::new();
|
||||
base64_engine.encode_string(&format!("{}:{}", user, password), &mut enc_str);
|
||||
Some(enc_str)
|
||||
}
|
||||
(Some(user), _) => {
|
||||
let mut enc_str = String::new();
|
||||
base64_engine.encode_string(&format!("{}:", user), &mut enc_str);
|
||||
Some(enc_str)
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user