diff options
author | Alex Auvolat <alex@adnab.me> | 2024-03-07 12:46:15 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2024-03-07 13:42:01 +0100 |
commit | eab2b81be2a81422b829e7ef167de7b284695c28 (patch) | |
tree | d51c5e5b4b7f17522f702d2f31bab54213da8e05 /src/api | |
parent | 3168bb34a0082480660e945f7390a5ecab26c665 (diff) | |
download | garage-eab2b81be2a81422b829e7ef167de7b284695c28.tar.gz garage-eab2b81be2a81422b829e7ef167de7b284695c28.zip |
[unicode-headers] allow utf-8 in headers + add test for object metadata
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/s3/put.rs | 2 | ||||
-rw-r--r-- | src/api/signature/payload.rs | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/api/s3/put.rs b/src/api/s3/put.rs index 36523b30..685cca80 100644 --- a/src/api/s3/put.rs +++ b/src/api/s3/put.rs @@ -595,7 +595,7 @@ pub(crate) fn get_headers(headers: &HeaderMap<HeaderValue>) -> Result<ObjectVers // Preserve x-amz-meta- headers for (k, v) in headers.iter() { if k.as_str().starts_with("x-amz-meta-") { - match v.to_str() { + match std::str::from_utf8(v.as_bytes()) { Ok(v_str) => { other.insert(k.to_string(), v_str.to_string()); } diff --git a/src/api/signature/payload.rs b/src/api/signature/payload.rs index d72736bb..d6ff62f0 100644 --- a/src/api/signature/payload.rs +++ b/src/api/signature/payload.rs @@ -331,8 +331,8 @@ pub fn canonical_request( .map(|name| { let value = headers .get(name) - .ok_or_bad_request(format!("signed header `{}` is not present", name))? - .to_str()?; + .ok_or_bad_request(format!("signed header `{}` is not present", name))?; + let value = std::str::from_utf8(value.as_bytes())?; Ok(format!("{}:{}", name.as_str(), value.trim())) }) .collect::<Result<Vec<String>, Error>>()? |