Skip to content

Commit 099d22a

Browse files
Merge pull request #3054 from ThorstenHans/chore/cosmos-db-key-validation
Validate keys before persisting items in Azure CosmosDB key-value store
2 parents bd5457e + 4e0944a commit 099d22a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/key-value-azure/src/store.rs

+9
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ impl Store for AzureCosmosStore {
154154
}
155155

156156
async fn set(&self, key: &str, value: &[u8]) -> Result<(), Error> {
157+
let illegal_chars = ['/', '\\', '?', '#'];
158+
159+
if key.contains(|c| illegal_chars.contains(&c)) {
160+
return Err(Error::Other(format!(
161+
"Key contains an illegal character. Keys must not include any of: {}",
162+
illegal_chars.iter().collect::<String>()
163+
)));
164+
}
165+
157166
let pair = Pair {
158167
id: key.to_string(),
159168
value: value.to_vec(),

0 commit comments

Comments
 (0)