Skip to content

fix(upload): accept valid videos with generic or empty MIME types (#1475) - #1817

Open
Tarulatapriya wants to merge 1 commit into
reframe-oss:mainfrom
Tarulatapriya:fix/generic-mime-uploads
Open

Tarulatapriya wants to merge 1 commit into
reframe-oss:mainfrom
Tarulatapriya:fix/generic-mime-uploads

Conversation

@Tarulatapriya

Copy link
Copy Markdown
Contributor

Summary

Fixes #1475

Valid video files dropped or picked via OS file pickers or certain browsers sometimes come with empty ("") or generic MIME types (application/octet-stream, application/x-matroska). Previously, both useVideoEditor and FileUpload strictly required file.type.startsWith("video/"), causing valid videos to be rejected before magic byte inspection could verify them.

Changes

  • src/hooks/useVideoEditor.ts:
    • Allowed files with valid video extensions (.mp4, .mov, .avi, .webm, .mkv) and generic/empty MIME types ("", application/octet-stream, application/x-matroska) through Layer 1 and Layer 2 validation into Layer 3 (magic byte verification).
  • src/components/FileUpload.tsx:
    • Updated upload drop/selection validation to accept valid video extensions with generic or empty MIME types.
    • Added common extensions (.mp4,.mov,.avi,.webm,.mkv) to the file input's accept attribute alongside video/*.
  • src/hooks/tests/useVideoEditor.test.ts:
    • Added unit tests verifying acceptance of valid video extensions with empty/generic MIME types and rejection of non-video files.
    • Cleared test history state in beforeEach to prevent query param test leakage.

Testing

  • npm run test / vitest (all tests passing)
  • npx tsc --noEmit (clean)
  • npm run lint (clean)
  • npm run build (clean)

@netlify

netlify Bot commented Oct 18, 2026

Copy link
Copy Markdown

👷 Deploy request for reframe-os pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 760bc49

@github-actions github-actions Bot added level:intermediate Intermediate level - 35 pts type:bug Bug fix type:testing Testing labels Oct 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Format Check Passed — @Tarulatapriya

Basic format checks passed. A maintainer will review your code changes.

This does not mean the PR is approved — it just means the format is correct.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Thanks for your PR, @Tarulatapriya!

Welcome to Reframe — a browser-based video editor built for everyone 🎬

What happens next

  1. 🤖 Automated checks — build & TypeScript typecheck will run automatically
  2. ✅ Vercel preview — a preview deployment will be created (requires maintainer authorization for fork PRs)
  3. 👀 Code review — a maintainer will review your changes
  4. 🚀 Merge — once approved, your PR will be merged!

Quick checklist

  • PR title follows Conventional Commits (e.g. feat: add dark mode)
  • Linked the issue this PR closes (e.g. Closes #123)
  • Tested the changes locally (bun run dev)
  • Build passes (bun run build)

Useful links

Happy coding! 🎉

@chiragjangiir chiragjangiir left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a solid fix for issue #1475. Allowing generic MIME types (application/octet-stream, application/x-matroska, or empty "") when the filename extension matches a known video format addresses browser variance across OS file pickers (especially for .mkv files).

A couple of observations:

  1. DRY constants: validExtensions ([".mp4", ".mov", ".avi", ".webm", ".mkv"]) is defined identically in both FileUpload.tsx and useVideoEditor.ts. Moving it to src/lib/constants.ts (e.g. SUPPORTED_VIDEO_EXTENSIONS) would keep the validation rules synchronized in one place.
  2. Accept attribute: Adding ,.mp4,.mov,.avi,.webm,.mkv to the <input type="file" accept="..." /> attribute is great because some desktop environments fail to match .mkv against video/*.
  3. Tests: Nice unit tests in useVideoEditor.test.ts verifying both generic MIME acceptance with valid extension and rejection with non-video extensions.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:intermediate Intermediate level - 35 pts type:bug Bug fix type:testing Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Uploader rejects valid videos with generic MIME types

2 participants