Skip to content

[Bugfix:Submission] Fix BMP for file display#12623

Merged
bmcutler merged 9 commits into
Submitty:mainfrom
itsjanajana:fix-bmp-mime-clean
Apr 10, 2026
Merged

[Bugfix:Submission] Fix BMP for file display#12623
bmcutler merged 9 commits into
Submitty:mainfrom
itsjanajana:fix-bmp-mime-clean

Conversation

@itsjanajana

Copy link
Copy Markdown
Contributor

Why is this Change Important & Necessary?

Fixes #6583 BMP image created from Windows Paint triggers download on Chrome/Edge
BMP files created from WindowsPaint and other applications are in format of image/x-ms-bmp. But, Chrome and Edge expect the files in format of image/bmp. So, Chrome and Edge handle it incorrectly, and download the file. This prevents the image from appearing inline and makes grading difficult. This PR fixes BMP file rendering without changing any other image formats.

What is the New Behavior?

Screenshot 2026-03-22 034541

Old Behavior:
BMP file is in image/x-ms-bmp format and instead of displaying the image inline:

  1. The file gets downloaded
  2. The viewer shows nothing inline
Screenshot 2026-03-22 034954 Screenshot 2026-03-22 035752

New behavior:

  1. BMP files display inline in the browser
  2. No downloads happen
  3. Any MIME type containing "bmp" is normalized to image/bmp(As shown above, non-Paint BMP files also display correctly. I have verified and attached above)

What steps should a reviewer take to reproduce or test the bug or new feature?

  1. Login as student, Submit a BMP file on any gradeable that uploads files. I did Upload Only Gradeable
  2. Login as TA, Open the BMP file in grading view.
  3. Before the change, the BMP file will download
  4. After the change, it will display inline. All BMP files, including ones that are not Paint app files.

Automated Testing & Documentation

No new automated tests added, It is a minor MIME fix. Change only in file MiscController.php
No additional documentation changes
I have manually tested in local environment

Other information

Is this a breaking change? No
Does this PR include migrations to update existing installations? No
Are there security concerns with this PR? No

@codecov

codecov Bot commented Mar 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.64%. Comparing base (05dae18) to head (392e297).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main   #12623      +/-   ##
============================================
- Coverage     21.64%   21.64%   -0.01%     
- Complexity     9654     9655       +1     
============================================
  Files           268      268              
  Lines         36244    36246       +2     
  Branches        487      487              
============================================
  Hits           7845     7845              
- Misses        27916    27918       +2     
  Partials        483      483              
Flag Coverage Δ
autograder 21.32% <ø> (ø)
js 2.04% <ø> (ø)
migrator 100.00% <ø> (ø)
php 20.66% <0.00%> (-0.01%) ⬇️
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 91.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@itsjanajana itsjanajana changed the title Fix BMP MIME type handling in file display [Bugfix:Submission] Fix BMP MIME type handling for file display Mar 23, 2026

@dagemcn dagemcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good, the fix works as intended. Address failing CIs and I'll approve, they should be fairly easy fixes.

@github-project-automation github-project-automation Bot moved this from Seeking Reviewer to Work in Progress in Submitty Development Mar 24, 2026
@itsjanajana itsjanajana changed the title [Bugfix:Submission] Fix BMP MIME type handling for file display [Bugfix:Submission] Fix BMP for file display Mar 29, 2026
@itsjanajana

Copy link
Copy Markdown
Contributor Author

@dagemcn
I have fixed the issues that failed:

  • Fixed PHP Lint (indentation issues)
  • Updated PR title to be shorter than 40 characters
    Please do let me know if anything else needs an improvement, thankyou

@itsjanajana
itsjanajana requested a review from dagemcn April 1, 2026 12:33
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Apr 1, 2026

@dagemcn dagemcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@github-project-automation github-project-automation Bot moved this from In Review to Awaiting Maintainer Review in Submitty Development Apr 3, 2026
@bmcutler
bmcutler merged commit e32e878 into Submitty:main Apr 10, 2026
25 checks passed
@github-project-automation github-project-automation Bot moved this from Awaiting Maintainer Review to Done in Submitty Development Apr 10, 2026
GarvitKhandelwal31 pushed a commit to GarvitKhandelwal31/Submitty that referenced this pull request Apr 13, 2026
## Why is this Change Important & Necessary?
_Fixes Submitty#6583 BMP image created from Windows Paint triggers download on
Chrome/Edge_
BMP files created from WindowsPaint and other applications are in format
of `image/x-ms-bmp`. But, Chrome and Edge expect the files in format of
`image/bmp`. So, Chrome and Edge handle it incorrectly, and download the
file. This prevents the image from appearing inline and makes grading
difficult. This PR fixes BMP file rendering without changing any other
image formats.

## What is the New Behavior?
<img width="2878" height="1543" alt="Screenshot 2026-03-22 034541"
src="https://github.com/user-attachments/assets/2a86ae35-cd51-4e78-97ee-bf34ae900d63"
/>

**Old Behavior:**
BMP file is in image/x-ms-bmp format and instead of displaying the image
inline:
1. The file gets downloaded 
2. The viewer shows nothing inline

<img width="2879" height="1483" alt="Screenshot 2026-03-22 034954"
src="https://github.com/user-attachments/assets/6c8dab1e-3cb7-4c58-b649-8626717a622f"
/>
<img width="2877" height="1486" alt="Screenshot 2026-03-22 035752"
src="https://github.com/user-attachments/assets/f7c85aab-711b-4bee-8480-8ad227d5d753"
/>

**New behavior:** 
1. BMP files display inline in the browser
2. No downloads happen
3. Any MIME type containing "bmp" is normalized to image/bmp(As shown
above, non-Paint BMP files also display correctly. I have verified and
attached above)

## What steps should a reviewer take to reproduce or test the bug or new
feature?

1. Login as student, Submit a BMP file on any gradeable that uploads
files. I did Upload Only Gradeable
2. Login as TA, Open the BMP file in grading view. 
3. Before the change, the BMP file will download
4. After the change, it will display inline. All BMP files, including
ones that are not Paint app files.


## Automated Testing & Documentation
No new automated tests added, It is a minor MIME fix. Change only in
file MiscController.php
No additional documentation changes
I have manually tested in local environment

## Other information
Is this a breaking change? No
Does this PR include migrations to update existing installations? No
Are there security concerns with this PR? No

---------

Co-authored-by: dagemcn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

BMP image created from Windows paint triggers download on Chrome/Edge

3 participants