A file's revision reads the same after a save as it does when listed #3

Merged
temeddix merged 2 commits from etag-one-spelling into main 2026-09-25 17:43:51 +00:00
Showing only changes of commit c7998e6f7a - Show all commits
+4 -2
View File
@@ -212,10 +212,11 @@ pub fn multistatus(body: &[u8]) -> Result<Vec<Found>, ErrorCode> {
/// Some servers, WsgiDAV among them, list `getetag` bare while their `ETag` /// Some servers, WsgiDAV among them, list `getetag` bare while their `ETag`
/// header quotes the same tag, so a revision read from a listing and one /// header quotes the same tag, so a revision read from a listing and one
/// returned by a write would differ for the same bytes. Quoting a bare tag /// returned by a write would differ for the same bytes. Quoting a bare tag
/// gives every revision one spelling, and `If-Match` accepts that form. /// gives every revision one spelling, and `If-Match` accepts that form. A tag
/// that is already quoted, weak or strong, is kept as it is.
pub fn etag(value: &str) -> String { pub fn etag(value: &str) -> String {
let value = value.trim(); let value = value.trim();
Review

A bare opaque tag can legitimately begin with W/; this branch leaves it unquoted, so it still differs from the corresponding ETag: "W/..." header and breaks revision equality. Preserve only a syntactically quoted weak tag (W/"…"), quote all other bare values, and cover that case.

Profile: codex · gpt-5.6-terra

A bare opaque tag can legitimately begin with `W/`; this branch leaves it unquoted, so it still differs from the corresponding `ETag: "W/..."` header and breaks revision equality. Preserve only a syntactically quoted weak tag (`W/"…"`), quote all other bare values, and cover that case. > Profile: `codex` · `gpt-5.6-terra`
if value.starts_with('"') || value.starts_with("W/") { if value.starts_with('"') || value.starts_with("W/\"") {
value.to_owned() value.to_owned()
} else { } else {
format!("\"{value}\"") format!("\"{value}\"")
@@ -435,5 +436,6 @@ mod tests {
assert_eq!(etag("1996000-1790356720-264"), "\"1996000-1790356720-264\""); assert_eq!(etag("1996000-1790356720-264"), "\"1996000-1790356720-264\"");
assert_eq!(etag(" \"v1\" "), "\"v1\""); assert_eq!(etag(" \"v1\" "), "\"v1\"");
assert_eq!(etag("W/\"v1\""), "W/\"v1\""); assert_eq!(etag("W/\"v1\""), "W/\"v1\"");
assert_eq!(etag("W/v1"), "\"W/v1\"");
} }
} }