Skip to content

fix: tighten MIME type validation regex (#35)#60

Merged
cmeans-claude-dev[bot] merged 1 commit into
mainfrom
fix/mime-whitelist-35
Apr 12, 2026
Merged

fix: tighten MIME type validation regex (#35)#60
cmeans-claude-dev[bot] merged 1 commit into
mainfrom
fix/mime-whitelist-35

Conversation

@cmeans-claude-dev
Copy link
Copy Markdown
Contributor

@cmeans-claude-dev cmeans-claude-dev Bot commented Apr 12, 2026

Summary

  • MIME type and subtype must now start with a letter (rejects 123/456, _/_)
  • Parameter syntax validated as name=value (rejects ;garbage)
  • Custom MIME types like application/x-custom still accepted

Test plan

  • uv run pytest tests/test_server.py::test_read_raw_rejects_numeric_mime -v passes
  • uv run pytest tests/test_server.py::test_read_raw_rejects_underscore_mime -v passes
  • uv run pytest tests/test_server.py::test_read_raw_accepts_custom_mime -v passes
  • Full suite: uv run pytest -q -- 453 passed, 6 deselected, 8 xfailed

Closes #35

Type and subtype must now start with a letter. Rejects values
like 123/456 and _/_ that previously passed. Parameter syntax
now requires name=value format.

Closes #35

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cmeans-claude-dev cmeans-claude-dev Bot added the Ready for QA Dev work complete — QA can begin review label Apr 12, 2026
@github-actions github-actions Bot added Awaiting CI Dev complete, waiting for CI/Codecov to pass before QA Ready for QA Dev work complete — QA can begin review and removed Ready for QA Dev work complete — QA can begin review Awaiting CI Dev complete, waiting for CI/Codecov to pass before QA labels Apr 12, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cmeans cmeans added QA Active QA is actively reviewing; Dev should not push changes and removed Ready for QA Dev work complete — QA can begin review labels Apr 12, 2026
Copy link
Copy Markdown
Owner

@cmeans cmeans left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Owner

@cmeans cmeans left a comment

Choose a reason for hiding this comment

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

QA Review — PR #60

Verdict: Zero findings. Ready for maintainer signoff.

Checkboxes verified

CHECKBOX 1: test_read_raw_rejects_numeric_mime     → PASSED (123/456 rejected)
CHECKBOX 2: test_read_raw_rejects_underscore_mime   → PASSED (_/_ rejected)
CHECKBOX 3: test_read_raw_accepts_custom_mime        → PASSED (application/x-custom accepted)
CHECKBOX 4: pytest -q                               → 453 passed, 6 deselected, 8 xfailed

All checkboxes ticked.

Code review

Old regex: r"^[\w.+\-]+/[\w.+\-]+(;[\w.+\-=]+)*$" — accepted 123/456, _/_, ;garbage
New regex: r"^[a-zA-Z][\w.+\-]*/[a-zA-Z][\w.+\-]*(;\s*[\w.+\-]+=[\w.+\-]+)*$" — type/subtype must start with a letter, parameters must be name=value

Per RFC 2045 §5.1, type and subtype tokens must start with a letter. The new regex is more RFC-compliant. \s* after ; allows ; charset=utf-8 (common in the wild). Custom types like application/x-custom still pass. ✓

Other checks

  • CHANGELOG: ### Fixed in [Unreleased]. Accurate. Closes #35. ✓
  • CI: All green. ✓
  • Diff scope: 3 files, +30/-2, single commit. Clean. ✓

Findings

None.

@cmeans
Copy link
Copy Markdown
Owner

cmeans commented Apr 12, 2026

Applying Ready for QA Signoff. All 4 checkboxes verified and ticked. Regex now RFC 2045 compliant — type/subtype must start with letter, parameters require name=value. 453/453 pass. Zero findings.

@cmeans cmeans added Ready for QA Signoff QA passed — ready for maintainer final review and merge QA Approved Manual QA testing completed and passed and removed QA Active QA is actively reviewing; Dev should not push changes Ready for QA Signoff QA passed — ready for maintainer final review and merge labels Apr 12, 2026
@cmeans-claude-dev cmeans-claude-dev Bot merged commit 62893c3 into main Apr 12, 2026
39 checks passed
@cmeans-claude-dev cmeans-claude-dev Bot deleted the fix/mime-whitelist-35 branch April 12, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QA Approved Manual QA testing completed and passed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MIME type validation regex is overly permissive

1 participant