mirror of
https://github.com/nushell/nushell
synced 2024-11-13 08:27:06 +00:00
fix: filename quoting # and update and unify surf dependency (#3524)
* fix: filenames with '#' don't get quoted #3496 * updating and unifying dependency surf * adding hyper-client Co-authored-by: ahkrr <alexhk@protonmail.com>
This commit is contained in:
parent
01f1208ad1
commit
be9ebd9e18
3 changed files with 13 additions and 13 deletions
|
@ -138,7 +138,7 @@ fn requote(orig_value: String) -> String {
|
|||
let mut quotes = vec!['"', '\'', '`'];
|
||||
let mut should_quote = false;
|
||||
for c in value.chars() {
|
||||
if c.is_whitespace() {
|
||||
if c.is_whitespace() || c == '#' {
|
||||
should_quote = true;
|
||||
} else if let Some(index) = quotes.iter().position(|q| *q == c) {
|
||||
should_quote = true;
|
||||
|
|
|
@ -12,13 +12,14 @@ doctest = false
|
|||
[dependencies]
|
||||
base64 = "0.13.0"
|
||||
futures = { version = "0.3.5", features = ["compat", "io-compat"] }
|
||||
mime = "0.3.16"
|
||||
nu-errors = { path = "../nu-errors", version = "0.31.1" }
|
||||
nu-plugin = { path = "../nu-plugin", version = "0.31.1" }
|
||||
nu-protocol = { path = "../nu-protocol", version = "0.31.1" }
|
||||
nu-source = { path = "../nu-source", version = "0.31.1" }
|
||||
num-traits = "0.2.12"
|
||||
serde_json = "1.0.57"
|
||||
surf = "1.0.3"
|
||||
surf = "2.2.0"
|
||||
url = "2.1.1"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -9,7 +9,6 @@ use nu_source::{AnchorLocation, Tag, TaggedItem};
|
|||
use num_traits::cast::ToPrimitive;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use surf::mime;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum HeaderKind {
|
||||
|
@ -133,15 +132,15 @@ pub async fn post(
|
|||
value: UntaggedValue::Primitive(Primitive::String(body_str)),
|
||||
..
|
||||
} => {
|
||||
let mut s = surf::post(location).body_string(body_str.to_string());
|
||||
let mut s = surf::post(location).body(body_str.to_string());
|
||||
if let Some(login) = login {
|
||||
s = s.set_header("Authorization", format!("Basic {}", login));
|
||||
s = s.header("Authorization", format!("Basic {}", login));
|
||||
}
|
||||
|
||||
for h in headers {
|
||||
s = match h {
|
||||
HeaderKind::ContentType(ct) => s.set_header("Content-Type", ct),
|
||||
HeaderKind::ContentLength(cl) => s.set_header("Content-Length", cl),
|
||||
HeaderKind::ContentType(ct) => s.header("Content-Type", ct),
|
||||
HeaderKind::ContentLength(cl) => s.header("Content-Length", cl),
|
||||
};
|
||||
}
|
||||
s.await
|
||||
|
@ -150,9 +149,9 @@ pub async fn post(
|
|||
value: UntaggedValue::Primitive(Primitive::Binary(b)),
|
||||
..
|
||||
} => {
|
||||
let mut s = surf::post(location).body_bytes(b);
|
||||
let mut s = surf::post(location).body(&b[..]);
|
||||
if let Some(login) = login {
|
||||
s = s.set_header("Authorization", format!("Basic {}", login));
|
||||
s = s.header("Authorization", format!("Basic {}", login));
|
||||
}
|
||||
s.await
|
||||
}
|
||||
|
@ -160,10 +159,10 @@ pub async fn post(
|
|||
match value_to_json_value(&value.clone().into_untagged_value()) {
|
||||
Ok(json_value) => match serde_json::to_string(&json_value) {
|
||||
Ok(result_string) => {
|
||||
let mut s = surf::post(location).body_string(result_string);
|
||||
let mut s = surf::post(location).body(result_string);
|
||||
|
||||
if let Some(login) = login {
|
||||
s = s.set_header("Authorization", format!("Basic {}", login));
|
||||
s = s.header("Authorization", format!("Basic {}", login));
|
||||
}
|
||||
s.await
|
||||
}
|
||||
|
@ -186,9 +185,9 @@ pub async fn post(
|
|||
}
|
||||
};
|
||||
match response {
|
||||
Ok(mut r) => match r.headers().get("content-type") {
|
||||
Ok(mut r) => match r.header("content-type") {
|
||||
Some(content_type) => {
|
||||
let content_type = Mime::from_str(content_type).map_err(|_| {
|
||||
let content_type = Mime::from_str(content_type.as_str()).map_err(|_| {
|
||||
ShellError::labeled_error(
|
||||
format!("Unknown MIME type: {}", content_type),
|
||||
"unknown MIME type",
|
||||
|
|
Loading…
Reference in a new issue