Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
Replace x-www-form-url encoding with percent encoding in blob/contain…
Browse files Browse the repository at this point in the history
…er signature generation (#318)

* replace form url encoding with percent encoding

* fixed example missing a dependency

* less verbose code

* less verbose code (forgot some :)
  • Loading branch information
Francesco Cogno authored Sep 11, 2020
1 parent 2b48b8a commit 5127783
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
5 changes: 3 additions & 2 deletions azure_sdk_storage_blob/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "azure_sdk_storage_blob"
version = "0.45.2"
version = "0.45.3"
description = "Rust wrappers around Microsoft Azure REST APIs - Blob storage crate"
readme = "README.md"
authors = ["Francesco Cogno <[email protected]>", "Max Gortman <[email protected]>", "Dong Liu <[email protected]>"]
Expand Down Expand Up @@ -28,13 +28,14 @@ log = "0.4"
serde = "1.0"
serde_derive = "1.0"
serde-xml-rs = "0.4"
url = "2.1"
uuid = { version = "0.8", features = ["v4"] }
percent-encoding = "2.1"

[dev-dependencies]
env_logger = "0.7"
tokio = { version = "0.2", features = ["macros"] }
azure_sdk_auth_aad = { path = "../azure_sdk_auth_aad" }
url = "2.1"

[features]
default = [ "azure_sdk_core" ]
Expand Down
27 changes: 13 additions & 14 deletions azure_sdk_storage_blob/src/blob/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ use azure_sdk_core::headers::{
COPY_SOURCE, COPY_STATUS, COPY_STATUS_DESCRIPTION, CREATION_TIME, LEASE_DURATION, LEASE_STATE,
LEASE_STATUS, SERVER_ENCRYPTED,
};
use azure_sdk_storage_core::Client;
use chrono::{DateTime, Utc};
use hyper::header;
use std::borrow::Borrow;
use std::collections::HashMap;
use std::str::FromStr;
use url::form_urlencoded;
use xml::Element;
use xml::Xml::ElementNode;

use azure_sdk_core::{
errors::{AzureError, TraversingError},
incompletevector::IncompleteVector,
Expand All @@ -39,6 +29,15 @@ use azure_sdk_core::{
range::Range,
util::HeaderMapExt,
};
use azure_sdk_storage_core::Client;
use chrono::{DateTime, Utc};
use hyper::header;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use std::borrow::Borrow;
use std::collections::HashMap;
use std::str::FromStr;
use xml::Element;
use xml::Xml::ElementNode;

#[cfg(feature = "azurite_workaround")]
fn get_creation_time(h: &header::HeaderMap) -> Result<Option<DateTime<Utc>>, AzureError> {
Expand Down Expand Up @@ -464,15 +463,15 @@ where
Some(ref params) => format!(
"{}/{}/{}?{}",
t.blob_uri(),
form_urlencoded::byte_serialize(container_name.as_bytes()).collect::<String>(),
form_urlencoded::byte_serialize(blob_name.as_bytes()).collect::<String>(),
utf8_percent_encode(container_name, NON_ALPHANUMERIC),
utf8_percent_encode(blob_name, NON_ALPHANUMERIC),
params
),
None => format!(
"{}/{}/{}",
t.blob_uri(),
form_urlencoded::byte_serialize(container_name.as_bytes()).collect::<String>(),
form_urlencoded::byte_serialize(blob_name.as_bytes()).collect::<String>(),
utf8_percent_encode(container_name, NON_ALPHANUMERIC),
utf8_percent_encode(blob_name, NON_ALPHANUMERIC),
),
}
}
Expand Down
6 changes: 3 additions & 3 deletions azure_sdk_storage_blob/src/container/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use http::request::Builder;
use http::HeaderMap;
use hyper::header;
use hyper::header::HeaderName;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use std::collections::HashMap;
use std::str::FromStr;
use url::form_urlencoded;
use xml::{Element, Xml};

create_enum!(
Expand Down Expand Up @@ -285,13 +285,13 @@ where
Some(ref params) => format!(
"{}/{}?{}",
c.blob_uri(),
form_urlencoded::byte_serialize(container_name.as_bytes()).collect::<String>(),
utf8_percent_encode(container_name, NON_ALPHANUMERIC),
params
),
None => format!(
"{}/{}",
c.blob_uri(),
form_urlencoded::byte_serialize(container_name.as_bytes()).collect::<String>(),
utf8_percent_encode(container_name, NON_ALPHANUMERIC),
),
}
}

0 comments on commit 5127783

Please sign in to comment.