Skip to content

Parse parameterized multipart headers. - #2

Merged
samuel-williams-shopify merged 7 commits into
mainfrom
parse-parameterized-headers
Aug 2, 2026
Merged

Parse parameterized multipart headers.#2
samuel-williams-shopify merged 7 commits into
mainfrom
parse-parameterized-headers

Conversation

@samuel-williams-shopify

@samuel-williams-shopify samuel-williams-shopify commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Add Protocol::Multipart::Header for strict, linear parsing of parameterized multipart header values, including Content-Type and Content-Disposition. It supports token and quoted values, quoted-pair escapes and UTF-8 quoted filenames while rejecting malformed syntax, duplicate parameters, control characters and folded values.

Add Protocol::Multipart::Headers, backed by Protocol::HTTP::Headers with a multipart-specific policy. Parsed parts preserve ordered header fields and repeated extension fields, while duplicate singular MIME metadata such as Content-Type and Content-Disposition is rejected. Part header lines reject obsolete folding, whitespace before the colon and embedded control characters.

This avoids the parsing ambiguities and super-linear compatibility paths that have repeatedly caused Rack multipart vulnerabilities. The initial protocol-http dependency keeps the implementation focused; the generic header container can be extracted later if another protocol needs it.

Testing

  • bake test
  • bake covered:validate --paths .covered.db
  • rubocop
  • bake decode:index:coverage lib

@samuel-williams-shopify
samuel-williams-shopify force-pushed the parse-parameterized-headers branch from 4301646 to fa12954 Compare August 2, 2026 22:58
@samuel-williams-shopify
samuel-williams-shopify merged commit b803777 into main Aug 2, 2026
40 checks passed
@samuel-williams-shopify
samuel-williams-shopify deleted the parse-parameterized-headers branch August 2, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant