Skip to main content

validate_key

Function validate_key 

Source
pub fn validate_key(key: &str) -> Result<(), ProxyError>
Expand description

Validate a client-visible object key before any backend path is built.

Every backend URL builder must agree on what a key addresses. The presigned path’s Path::parse rejects empty and ./.. segments but silently strips a leading/trailing /; the raw-signed path (build_backend_url) would accept all of them — writing objects the presigned path can’t address, breaking listings (object_store fails to parse listed keys with empty segments), and letting a literal .. reach URL normalization. Reject the whole class loudly, once, for every keyed operation. Real S3 accepts these keys; the proxy is deliberately stricter. Batch-delete body keys are deliberately exempt — they never enter a URL path, and permissiveness there is the remediation route for legacy degenerate keys already on a backend.