This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Fabien Potencier e4a7fd8eed bug #29271 [HttpFoundation] Fix trailing space for mime-type with parameters (Sascha Dens)
This PR was merged into the 2.8 branch.

Discussion
----------

[HttpFoundation] Fix trailing space for mime-type with parameters

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->
This PR fixes a minor issue that we've discovered by exposing our API towards mobile applications which where sending the header as following `content-type: application/json ;charset=UTF-8`. Request is unable to determine the `getContentType -> getFormat` as **json** due to the whitespace at the end.

```php
$request = Request::createFromGlobals();
$request->headers->set('CONTENT_TYPE', 'application/json ;charset=UTF-8'); // Forcing header for test
if ($request->getContentType() !== 'json') {
    // Return 415 (Unsupported Media Type) status code..
}
```

When checking https://tools.ietf.org/html/rfc7231#section-3.1.1.1 it seems that a space is part of the RFC spec. (Where OWS is abbreviated for Optional WhiteSpace)
```
media-type = type "/" subtype *( OWS ";" OWS parameter )
```
Current the following cases are supported:
* application/json; charset=UTF-8
* application/json;charset=UTF-8

The following are failing:
* application/json ; charset=UTF-8
* application/json ;charset=UTF-8

Commits
-------

f4866bc371 [HttpFoundation] Fix trailing space for mime-type with parameters
2018-11-22 11:33:55 +01:00
.composer Drop hirak/prestissimo 2016-05-12 07:44:15 -05:00
.github invalidate stale commits for PRs too 2018-10-09 14:32:52 +02:00
src/Symfony bug #29271 [HttpFoundation] Fix trailing space for mime-type with parameters (Sascha Dens) 2018-11-22 11:33:55 +01:00
.appveyor.yml [appveyor] fix 2018-09-05 13:43:17 +02:00
.editorconfig Update .editorconfig 2018-09-06 16:22:56 +02:00
.gitignore Add appveyor.yml for C.I. on Windows 2015-08-25 23:41:37 +02:00
.php_cs.dist [CS] Enable phpdoc_types_order 2018-10-10 21:53:33 -03:00
.travis.yml [Travis] Bump ext-mongodb to 1.5.2 on Travis 2018-11-06 16:30:18 +01:00
CHANGELOG-2.2.md Merge branch '2.2' into 2.3 2013-12-03 15:51:26 +01:00
CHANGELOG-2.3.md updated CHANGELOG for 2.3.42 2016-05-30 10:40:50 +02:00
CHANGELOG-2.4.md updated CHANGELOG for 2.4.9 2014-09-03 11:50:09 +02:00
CHANGELOG-2.5.md updated CHANGELOG for 2.5.10 2015-02-02 10:26:02 +01:00
CHANGELOG-2.6.md updated CHANGELOG for 2.6.10 2015-07-13 11:34:21 +02:00
CHANGELOG-2.7.md updated CHANGELOG for 2.7.47 2018-05-21 13:47:41 +02:00
CHANGELOG-2.8.md updated CHANGELOG for 2.8.47 2018-11-03 10:53:41 +01:00
CODE_OF_CONDUCT.md Added the Code of Conduct file 2018-10-10 03:13:30 -07:00
CONTRIBUTING.md Mention the community review guide 2016-12-18 22:02:35 +01:00
CONTRIBUTORS.md update CONTRIBUTORS for 2.8.47 2018-11-03 10:53:55 +01:00
LICENSE fixed years in copyright 2018-01-03 08:23:28 +01:00
README.md Add code of Conduct links in our README 2018-05-25 16:34:01 +02:00
UPGRADE-2.1.md Remove aligned '=>' and '=' 2014-10-26 08:30:58 +01:00
UPGRADE-2.2.md Clean up 2018-01-02 16:37:23 +01:00
UPGRADE-2.3.md [Doc] Use Markdown syntax highlighting 2014-10-01 07:38:33 +02:00
UPGRADE-2.4.md Updated UPGRADE-2.4.md 2015-06-08 16:44:57 +02:00
UPGRADE-2.5.md Clean up 2018-01-02 16:37:23 +01:00
UPGRADE-2.6.md Fix grammar 2014-12-30 09:24:50 +01:00
UPGRADE-2.7.md Add framework asset changes to upgrade 3.0 guide 2018-11-06 16:58:15 +01:00
UPGRADE-2.8.md fixed CS 2017-08-10 08:50:59 +02:00
UPGRADE-3.0.md Add framework asset changes to upgrade 3.0 guide 2018-11-06 16:58:15 +01:00
composer.json Merge branch '2.7' into 2.8 2018-05-01 15:52:40 -07:00
link Update Repository Symlink Helper 2018-02-11 12:15:02 +01:00
phpunit Default testsuite to latest PHPUnit 6.* 2018-05-25 15:04:04 +02:00
phpunit.xml.dist minor #29174 Add required key attribute (greg0ire) 2018-11-11 20:41:05 +01:00

README.md

Symfony is a PHP framework for web applications and a set of reusable PHP components. Symfony is used by thousands of web applications (including BlaBlaCar.com and Spotify.com) and most of the popular PHP projects (including Drupal and Magento).

Installation

Documentation

Community

Contributing

Symfony is an Open Source, community-driven project with thousands of contributors. Join them contributing code or contributing documentation.

Security Issues

If you discover a security vulnerability within Symfony, please follow our disclosure procedure.

About Us

Symfony development is sponsored by SensioLabs, led by the Symfony Core Team and supported by Symfony contributors.