python-openapi / openapi-core

Openapi-core is a Python library that adds client-side and server-side support for the OpenAPI v3.0 and OpenAPI v3.1 specification.
BSD 3-Clause "New" or "Revised" License
299 stars 132 forks source link

Fix content-type when no space after semicolon #814

Closed jonathanberthias closed 6 months ago

jonathanberthias commented 6 months ago

Currently, the Content-Type header splits the media type from the parameters by looking for ; (a semicolon followed by a space), whereas according to RFC 9110 that space is optional.

This leads to issues when a client sends e.g. application/json;charset=utf-8 which is valid as a Content Type header.

I used the examples from the RFC and made sure they are correctly handled. It isn't a full coverage of the allowed grammar, but hopefully it should cover most use cases.

codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 90.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 90.26%. Comparing base (9268452) to head (fb0ea95). Report is 11 commits behind head on master.

Files Patch % Lines
openapi_core/templating/media_types/finders.py 90.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #814 +/- ## ========================================== - Coverage 90.26% 90.26% -0.01% ========================================== Files 147 147 Lines 4294 4302 +8 Branches 523 524 +1 ========================================== + Hits 3876 3883 +7 Misses 317 317 - Partials 101 102 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

p1c2u commented 6 months ago

@jonathanberthias thanks for the contribution.