fix(isMimeType): allow underscores in parameterized MIME types - #2881
fix(isMimeType): allow underscores in parameterized MIME types#2881Jerry-val wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2881 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 114 114
Lines 2599 2599
Branches 658 658
=========================================
Hits 2599 2599 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
nrps9909
left a comment
There was a problem hiding this comment.
Verified exact head 85029bfc67e4a00c181c72606e168bc7edf7f399 against base a79ff980ab14257e795332989e497bdff3218e87.
Both added tests fail on the unchanged base; head passes full npm test (build, ESLint and 325 tests) on Node 24.15.0. All 13 reported upstream checks pass.
Independent checks cover underscore positions in parameter values, quoted/unquoted values at 1/2/69/70/71 characters, subtype positions around the existing 100-character implementation limit, IANA charset aliases, both multipart parameter orders, malformed quotes and unchanged supported/unsupported formats. Each of source, Node, browser and minified-browser forms runs 1,900 compatibility cases: base has 1,260 false rejects per form, head has zero mismatches in that scoped corpus.
The intended extension is supported by RFC 2046 §5.1.1, RFC 6838 §4.2, and the IANA charset aliases. The corpus preserves existing implementation limits; it is not an exhaustive RFC oracle.
I separately confirmed four unchanged limitations on both versions: an empty boundary and a quoted boundary ending in a space are accepted, while a quoted a:b boundary and a 101-character alphabetic subtype are rejected. These existing discrepancies are outside this underscore-only patch and are not represented as fixed or newly introduced. No objection to the scoped change.
AI-assisted review with independently executed validation; both worktrees are clean.
isMimeType('text/plain; charset=ANSI_X3.4-1968')andisMimeType('multipart/form-data; boundary=----Part_123')currently return false. Underscores are valid in these values: the charset is an IANA alias, and RFC 2046 explicitly includes_in multipart boundary characters.Add
_to the text/multipart subtype and quoted/unquoted parameter value character classes. This also makes parameterized subtype handling consistent with the simple MIME pattern, which already accepts underscores.This extends the cases covered by merged PR #2120: its actual change only updated the simple MIME pattern. I checked related open/closed MIME, charset and boundary PRs and found no matching implementation.
Validation:
npm test: 325 passing, including Node/ES/browser builds and ESLint.git diff --check: passed.References: RFC 2046 section 5.1.1, RFC 6838 section 4.2, IANA character sets.
Checklist