Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Zip files delivered via FileDownloadPage are invalid master #2453

Merged
merged 1 commit into from Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion backend/Origam.Server/Pages/StandardHttpResponseWrapper.cs
Expand Up @@ -57,11 +57,25 @@ public string ContentType
set
{
var mediaType = new MediaTypeHeaderValue(value);
mediaType.Encoding = encoding;
// if we're sending a zip file, we need to kick out the encoding
// otherwise the delivered file is invalid and of double size
if (!IsZipType(value)) {
mediaType.Encoding = encoding;
}
response.ContentType = mediaType.ToString();
}
}

private bool IsZipType(string contentType)
{
return contentType switch
{
"application/zip" => true,
"application/octet-stream" => true,
"application/x-zip-compressed" => true,
_ => false
};
}

public bool TrySkipIisCustomErrors
{
Expand Down