From 130e01505b1aa7cb9b3cf074dbc5d0269246b371 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 19 May 2023 12:52:28 +0200 Subject: Fix k2v_client with unicode in partition keys --- src/k2v-client/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/k2v-client/lib.rs') 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('?'); -- cgit v1.2.3