Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Adjust ContentType regex to allow quoted strings and equals #7374

Closed
wants to merge 1 commit into from
Closed

Adjust ContentType regex to allow quoted strings and equals #7374

wants to merge 1 commit into from

Conversation

asgrim
Copy link
Contributor

@asgrim asgrim commented Mar 27, 2015

This change modifies the regular expression in ContentType::fromString()
to allow parameters to contain the equals (=) character, and be
optionally enclosed in double quotes. For example the following header
is perfectly valid, but does not get currently parsed by ContentType:

Content-type: text/plain; charset="us-ascii"

Whilst allowing the parameter to be enclosed in double quotes, it should
not be included in the value itself, so these are outside the capture
group in the regular expression.

This change should resolve issue #7076.

This change modifies the regular expression in ContentType::fromString()
to allow parameters to contain the equals (=) character, and be
optionally enclosed in double quotes. For example the following header
is perfectly valid, but does not get currently parsed by ContentType:

  Content-type: text/plain; charset="us-ascii"

Whilst allowing the parameter to be enclosed in double quotes, it should
not be included in the value itself, so these are outside the capture
group in the regular expression.

This change should resolve issue #7076.
@weierophinney weierophinney added this to the 2.4.0 milestone Mar 27, 2015
weierophinney added a commit that referenced this pull request Mar 27, 2015
@asgrim asgrim deleted the fix-content-type-header-parse branch March 27, 2015 16:11
weierophinney added a commit to zendframework/zend-http that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants