mirror of
https://github.com/fluxerapp/fluxer.git
synced 2026-09-02 21:04:06 +03:00
fix(media-proxy): force SVG and PDF downloads (#1575)
This commit is contained in:
@@ -29,7 +29,7 @@ fn normalize_mime(content_type: &str) -> &str {
|
||||
|
||||
pub fn is_inline_viewable(content_type: &str) -> bool {
|
||||
let mime = normalize_mime(content_type);
|
||||
if mime.eq_ignore_ascii_case("image/svg+xml") {
|
||||
if is_scriptable_document(mime) {
|
||||
return false;
|
||||
}
|
||||
if mime.len() >= 6 && mime[..6].eq_ignore_ascii_case("image/") {
|
||||
@@ -38,7 +38,12 @@ pub fn is_inline_viewable(content_type: &str) -> bool {
|
||||
if mime.len() >= 6 && mime[..6].eq_ignore_ascii_case("video/") {
|
||||
return true;
|
||||
}
|
||||
mime.eq_ignore_ascii_case("application/pdf")
|
||||
false
|
||||
}
|
||||
|
||||
fn is_scriptable_document(mime: &str) -> bool {
|
||||
mime.eq_ignore_ascii_case("image/svg+xml")
|
||||
|| mime.eq_ignore_ascii_case("application/pdf")
|
||||
}
|
||||
|
||||
fn is_safe_quoted_filename(s: &str) -> bool {
|
||||
@@ -113,7 +118,7 @@ mod tests {
|
||||
decide("image/jpeg; charset=binary", false)
|
||||
);
|
||||
assert_eq!(Decision::Inline, decide("video/mp4", false));
|
||||
assert_eq!(Decision::Inline, decide("application/pdf", false));
|
||||
assert_eq!(Decision::Attachment, decide("application/pdf", false));
|
||||
assert_eq!(Decision::Attachment, decide("image/svg+xml", false));
|
||||
assert_eq!(
|
||||
Decision::Attachment,
|
||||
|
||||
Reference in New Issue
Block a user