mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-30 00:47:13 +00:00
a6a04b5faa
* refactor(ecstore,rustfs): reuse canonical starts_with_ignore_ascii_case `crates/utils/src/http/metadata_compat.rs` owns the internal metadata key helpers, including `starts_with_ignore_ascii_case`. Two files carried their own byte-identical copies of that predicate: `SetDisks::starts_with_ignore_ascii_case` in ecstore and a free function in the S3 options layer. Both drive internal metadata key classification (`internal_metadata_suffix` and quorum hashing on one side, `should_skip_object_metadata_key` and `is_reserved_user_metadata_key` on the other), so keeping three implementations of one predicate is an avoidable drift risk on a path that decides whether an internal key is treated as user metadata. Delete both local copies and call the canonical implementation. Every prefix used at these call sites is an ASCII constant or literal, where the canonical byte-slice comparison and the removed `str::get(..n)` form are equivalent; that equivalence was checked differentially over 4.6M (key, prefix) pairs, including keys with multi-byte characters straddling the prefix boundary. No other logic in `internal_metadata_suffix` or `should_skip_object_metadata_key` changed. Add regression tests on both sides pinning the two properties the switch depends on: internal prefixes match case-insensitively (a mixed-case `X-RustFS-Internal-*` key stays internal), and keys shorter than a prefix never match (they stay ordinary user metadata). Refs rustfs/backlog#2051 * fix(rustfs): avoid typos-checker false positive in prefix-length test The test literal "x-rustfs-encryptio" (a deliberate truncation of the x-rustfs-encryption- prefix, used to assert that a key shorter than every internal prefix falls through to user metadata) reads as a likely typo of "encryption" to the repo's typos CI check. Derive it from RUSTFS_ENCRYPTION_PREFIX via slicing instead of a hand-typed literal, which both satisfies the linter and ties the truncation to the real constant instead of a copy-typed guess. Refs rustfs/backlog#2051