Skip to content

fix(2.x): escape multipart filenames and field names - #987

Open
fengmk2 wants to merge 3 commits into
2.xfrom
codex/fix-multipart-2x
Open

fengmk2 wants to merge 3 commits into
2.xfrom
codex/fix-multipart-2x

Conversation

@fengmk2

@fengmk2 fengmk2 commented Nov 17, 2026

Copy link
Copy Markdown
Member

The 2.x multipart encoder relies on formstream. Older versions insert filenames and field names into headers without escaping them, which allows multipart header injection.

Require formstream@^1.5.3 to encode CR, LF, and double quotes in field names and filenames. MIME types containing CR or LF cause a synchronous TypeError. Use the upstream implementation directly and preserve the original paths for file access and filenames for MIME type detection.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 05:10
@agentscanapp

agentscanapp Bot commented Nov 17, 2026

Copy link
Copy Markdown

Automation signals

Activity patterns show signs of automation.

View full analysis →

Report this account →

Evidence
  • PRs to many projects in one day: Opened PRs in 69 different repos within 24 hours
  • Very high PR volume (daily): 72 PRs within a single 24-hour window, 39 of them to repos it can push to
  • High PR volume (weekly): 72 PRs within a single 7-day window, 39 of them to repos it can push to

Last 5 PRs:

This is an automated analysis by AgentScan

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 58cc0ddd-8d40-46c0-a668-cef1b9167bab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI 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.

🟢 Approval recommended

There are no active review issues for the multipart header-injection fix.

No open issues 🎉

What changed in this PR

This PR addresses multipart header injection in urllib’s 2.x branch by requiring upstream escaping from formstream.

Changes:

  • Raises the minimum formstream version to 1.5.3.
  • Adds regression tests for escaping quotes, CR, and LF in filenames and field names across buffer, stream, and file uploads.
  • Tests that escaping preserves filesystem access and leaves other filename characters unchanged.
File Description
test/​multipart-escaping.test.js Adds multipart escaping and filesystem-path regression tests.
package.json Updates formstream to ^1.5.3 for upstream header-injection protection.

Review effort: Balanced

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.94%. Comparing base (98b76ab) to head (ce1ad1b).

Additional details and impacted files
@@           Coverage Diff           @@
##              2.x     #987   +/-   ##
=======================================
  Coverage   89.94%   89.94%           
=======================================
  Files           6        6           
  Lines         875      875           
  Branches      243      243           
=======================================
  Hits          787      787           
  Misses         88       88           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants