The opaque content type is one core constant: local::OPAQUE_MIME

"application/octet-stream" was written out in the blob server, its test, the
store's normalize_mime and the wire default. All four now read OPAQUE_MIME; the
schema's SQL column default names the same string and says so.

DRY pass #2, batch 2, F7 (#5372).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 14:20:01 -04:00
co-authored by Claude Opus 5.5
parent 4ac15d3557
commit fe84924f78
4 changed files with 14 additions and 5 deletions
+4 -2
View File
@@ -12,6 +12,8 @@ use std::fs;
use std::path::{Path, PathBuf};
use std::sync::OnceLock;
use crate::local::OPAQUE_MIME;
/// A sha256 in lowercase hex, and nothing else.
///
/// This is a **path-safety** check, not a formatting nicety: the hash is taken
@@ -189,7 +191,7 @@ fn content_type_for(mime: &str) -> String {
if familiar && printable {
mime.to_string()
} else {
"application/octet-stream".to_string()
OPAQUE_MIME.to_string()
}
}
@@ -306,7 +308,7 @@ mod tests {
fn a_scriptable_type_is_served_as_a_download() {
// This scheme is an origin of its own. An attachment claiming to be HTML
// must not be handed back as a document that can run there.
let opaque = "application/octet-stream";
let opaque = OPAQUE_MIME;
assert_eq!(content_type_for("text/html"), opaque);
assert_eq!(content_type_for("application/javascript"), opaque);
// An image family member that is really a document with script in it.
+3 -1
View File
@@ -8,6 +8,8 @@
use serde::Deserialize;
use crate::local::OPAQUE_MIME;
#[derive(Debug, Clone, Deserialize, Default)]
pub struct ChangesPage {
#[serde(default)]
@@ -161,5 +163,5 @@ fn default_color() -> String {
}
fn default_mime() -> String {
"application/octet-stream".to_string()
OPAQUE_MIME.to_string()
}