max strip len config option

This commit is contained in:
minish 2024-05-27 13:12:18 -04:00
parent 7bfbe3b1fe
commit 2e92ab4bf0
Signed by: min
GPG Key ID: FEECFF24EF0CE9E9
2 changed files with 8 additions and 3 deletions

View File

@ -37,6 +37,10 @@ pub struct EngineConfig {
#[serde_as(as = "DurationSeconds")] #[serde_as(as = "DurationSeconds")]
pub max_temp_lifetime: Duration, pub max_temp_lifetime: Duration,
/// Maximum length (in bytes) a file can be before the server will
/// decide not to remove its EXIF data.
pub max_strip_len: usize,
/// Motd displayed when the server's index page is visited. /// Motd displayed when the server's index page is visited.
/// ///
/// This isn't explicitly engine-related but the engine is what gets passed to routes, /// This isn't explicitly engine-related but the engine is what gets passed to routes,
@ -73,6 +77,7 @@ pub struct CacheConfig {
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct HttpConfig { pub struct HttpConfig {
/// The IP address the HTTP server should listen on
pub listen_on: String, pub listen_on: String,
} }

View File

@ -196,7 +196,7 @@ impl Engine {
Some(Some("png" | "jpg" | "jpeg" | "webp" | "tiff")) Some(Some("png" | "jpg" | "jpeg" | "webp" | "tiff"))
) )
&& !keep_exif && !keep_exif
&& provided_len <= 16_777_216; && provided_len <= self.cfg.max_strip_len;
// read and save upload // read and save upload
while let Some(chunk) = stream.next().await { while let Some(chunk) = stream.next().await {