diff options
author | Alex Auvolat <alex@adnab.me> | 2023-05-19 12:52:28 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-05-22 10:45:09 +0200 |
commit | 130e01505b1aa7cb9b3cf074dbc5d0269246b371 (patch) | |
tree | 0b55f2dda34af5304a7ca62bbb4f6ed65e429583 | |
parent | e2ce5970c6c1ee26e5aabf6b5dba8d641416fb53 (diff) | |
download | garage-130e01505b1aa7cb9b3cf074dbc5d0269246b371.tar.gz garage-130e01505b1aa7cb9b3cf074dbc5d0269246b371.zip |
Fix k2v_client with unicode in partition keys
-rw-r--r-- | src/k2v-client/lib.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/k2v-client/lib.rs b/src/k2v-client/lib.rs index 2bc2f189..425c351f 100644 --- a/src/k2v-client/lib.rs +++ b/src/k2v-client/lib.rs @@ -33,6 +33,12 @@ const STRICT_ENCODE_SET: AsciiSet = NON_ALPHANUMERIC .remove(b'-') .remove(b'.') .remove(b'~'); +const PATH_ENCODE_SET: AsciiSet = NON_ALPHANUMERIC + .remove(b'/') + .remove(b'_') + .remove(b'-') + .remove(b'.') + .remove(b'~'); pub struct K2vClientConfig { pub endpoint: String, @@ -445,7 +451,7 @@ impl K2vClient { let mut url = format!("{}/{}", self.config.endpoint, self.config.bucket); if let Some(pk) = partition_key { url.push('/'); - url += pk; + url.extend(utf8_percent_encode(pk, &PATH_ENCODE_SET)); } if !query.is_empty() { url.push('?'); |