HomePhabricator

Add a rough HTTP header value parser

Description

Add a rough HTTP header value parser

Summary:
Ref T13008. Before we can disable enable_post_data_reading, we must be able to rebuild $_FILES ourselves. Before we can do this, we must be able to parse multipart/form-data requests. And, before we can do this, we must be able to parse complex HTTP headers, including these:

Content-Type: multipart/form-data; boundary="ABCDEFG"
Content-Disposition: form-data; name="something"; filename="something else"

Add a parser which can do this. The key parts are:

  • Picking the "boundary" out of the "Content-Type" header.
  • Picking all the stuff out of the "Content-Disposition" header for the actual multipart body.

This parser probably isn't perfect, but it will only be invoked when users upload vanilla files (e.g., "Change Profile Picture") so it's okay if it takes a while to sort out all the details.

Test Plan: Added unit tests, ran unit tests.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13008

Differential Revision: https://secure.phabricator.com/D18699

Details

Provenance
epriestleyAuthored on Oct 10 2017, 7:58 PM
epriestleyPushed on Oct 12 2017, 7:34 PM
Reviewer
amckinley
Differential Revision
D18699: Add a rough HTTP header value parser
Parents
rPHU9f9c33797a3e: Properly cache terminal width and dirty on SIGWINCH
Branches
Unknown
Tags
Unknown
Tasks
T13008: Process slot exhaustion in Phacility web tier
Build Status
Buildable 18674
Build 25157: Run Core Tests