Features/600394/al mime type consolidation#8418
Conversation
…me-type-consolidation
|
Could not find a linked ADO work item. Please link one by using the pattern 'AB#' followed by the relevant work item number. You may use the 'Fixes' keyword to automatically resolve the work item when the pull request is merged. E.g. 'Fixes AB#1234' |
| if LowerCaseFileName.EndsWith('.graphql') or LowerCaseFileName.EndsWith('.gql') then | ||
| exit('application/graphql'); | ||
| if LowerCaseFileName.EndsWith('.js') then | ||
| exit('application/javascript'); |
There was a problem hiding this comment.
Wrong MIME types for image extensions
The hardcoded overrides for .gif, .jpeg, .jpg, and .png use application/* prefixes (application/gif, application/jpeg, application/jpg, application/png). These are non-standard; the correct registered types are image/gif, image/jpeg, and image/png. These incorrect values will be returned instead of what MimeTypeUtility would correctly return, potentially breaking HTTP clients or email consumers that validate MIME types.
Recommendation:
- Remove these four override lines and let
MimeTypeUtility.GetMimeType()return the correctimage/*types. If.oggand.mpegoverrides are kept for backward-compatibility reasons, the image overrides should similarly be corrected or dropped.
| exit('application/javascript'); | |
| // Remove these lines and rely on MimeTypeUtility: | |
| // if LowerCaseFileName.EndsWith('.gif') then exit('application/gif'); | |
| // if LowerCaseFileName.EndsWith('.jpeg') then exit('application/jpeg'); | |
| // if LowerCaseFileName.EndsWith('.jpg') then exit('application/jpg'); | |
| // if LowerCaseFileName.EndsWith('.png') then exit('application/png'); | |
| exit(CopyStr(MimeTypeUtility.GetMimeType(FileName), 1, 250)); |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| if FileName.EndsWith('.js') then | ||
| exit('application/javascript'); | ||
| if FileName.EndsWith('.json') then | ||
| exit('application/json'); |
There was a problem hiding this comment.
Wrong MIME types for image extensions in Email
The same application/gif, application/jpeg, application/jpg, application/png non-standard MIME types are retained as hardcoded overrides. Email clients are strict about Content-Type headers; sending application/gif instead of image/gif as an attachment MIME type can cause attachments to not render inline or to fail virus-scanning gateways.
Recommendation:
- Remove the four incorrect image-type overrides and rely on
MimeTypeUtility.GetMimeType(), which should return the correctimage/*values.
| exit('application/json'); | |
| // Remove the four application/* image overrides; keep only those that differ from MimeTypeUtility: | |
| if LowerCaseFileName.EndsWith('.js') then exit('application/javascript'); | |
| if LowerCaseFileName.EndsWith('.mpeg') then exit('audio/mpeg'); | |
| if LowerCaseFileName.EndsWith('.ogg') then exit('audio/ogg'); | |
| if LowerCaseFileName.EndsWith('.php') then exit('text/php'); | |
| exit(CopyStr(MimeTypeUtility.GetMimeType(FileName), 1, 250)); |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| 'image/jpeg': | ||
| exit('jpeg'); | ||
| end; | ||
| exit(MimeTypeUtility.GetExtension(MimeType)); |
There was a problem hiding this comment.
Move this exist into case .. else.
It's clearer that way.
| 'text/html': | ||
| exit('.html'); | ||
| end; | ||
| Ext := MimeTypeUtility.GetExtension(BaseType); |
There was a problem hiding this comment.
This isn't a 1:1 replacement, are we confident in this?
Fx In the platform CU, image/gif is a missing mimetype.
| exit; | ||
| end; | ||
| end; | ||
| ContentType := CopyStr(MimeTypeUtility.GetMimeType('x.' + Rec."File Extension"), 1, 100); |
What & why
Linked work
Fixes #
How I validated this
What I tested and the outcome (required — be specific: scenarios, commands, screenshots for UI changes)
Risk & compatibility