Re: [Django] #36411: MediaType.get_preferred_type ignores params

13 views
Skip to first unread message

Django

unread,
May 29, 2025, 8:36:40 AM5/29/25
to django-...@googlegroups.com
#36411: MediaType.get_preferred_type ignores params
---------------------------------+---------------------------------------
Reporter: magicfelix | Owner: Jake Howard
Type: Bug | Status: assigned
Component: HTTP handling | Version: 5.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+---------------------------------------
Changes (by Natalia Bidart):

* cc: magicfelix (added)

Comment:

Replying to [ticket:36411 magicfelix]:

Hello! Could you please check if the proposed PR solves the issue for you?
--
Ticket URL: <https://code.djangoproject.com/ticket/36411#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 30, 2025, 6:39:15 AM5/30/25
to django-...@googlegroups.com
#36411: MediaType.get_preferred_type ignores params
---------------------------------+---------------------------------------
Reporter: magicfelix | Owner: Jake Howard
Type: Bug | Status: assigned
Component: HTTP handling | Version: 5.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+---------------------------------------
Comment (by magicfelix):

> Hello! Could you please check if the proposed PR solves the issue for
you?

It does, thanks :)
--
Ticket URL: <https://code.djangoproject.com/ticket/36411#comment:12>

Django

unread,
May 30, 2025, 9:54:27 AM5/30/25
to django-...@googlegroups.com
#36411: MediaType.get_preferred_type ignores params
---------------------------------+---------------------------------------
Reporter: magicfelix | Owner: Jake Howard
Type: Bug | Status: assigned
Component: HTTP handling | Version: 5.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+---------------------------------------
Changes (by Natalia Bidart):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36411#comment:13>

Django

unread,
Jun 3, 2025, 12:04:13 PM6/3/25
to django-...@googlegroups.com
#36411: MediaType.get_preferred_type ignores params
---------------------------------+---------------------------------------
Reporter: magicfelix | Owner: Jake Howard
Type: Bug | Status: assigned
Component: HTTP handling | Version: 5.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+---------------------------------------
Changes (by Jake Howard):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36411#comment:14>

Django

unread,
Jun 3, 2025, 1:58:54 PM6/3/25
to django-...@googlegroups.com
#36411: MediaType.get_preferred_type ignores params
-------------------------------------+-------------------------------------
Reporter: magicfelix | Owner: Jake
| Howard
Type: Bug | Status: assigned
Component: HTTP handling | Version: 5.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36411#comment:15>

Django

unread,
Jun 3, 2025, 3:10:54 PM6/3/25
to django-...@googlegroups.com
#36411: MediaType.get_preferred_type ignores params
-------------------------------------+-------------------------------------
Reporter: magicfelix | Owner: Jake
| Howard
Type: Bug | Status: closed
Component: HTTP handling | Version: 5.2
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nessita <124304+nessita@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"c075508b4de8edf9db553b409f8a8ed2f26ecead" c075508b]:
{{{#!CommitTicketReference repository=""
revision="c075508b4de8edf9db553b409f8a8ed2f26ecead"
Fixed #36411 -- Made HttpRequest.get_preferred_type() consider media type
parameters.

HttpRequest.get_preferred_type() did not account for parameters in
Accept header media types (e.g., "text/vcard; version=3.0"). This caused
incorrect content negotiation when multiple types differed only by
parameters, reducing specificity as per RFC 7231 section 5.3.2
(https://datatracker.ietf.org/doc/html/rfc7231.html#section-5.3.2).

This fix updates get_preferred_type() to treat media types with
parameters as distinct, allowing more precise and standards-compliant
matching.

Thanks to magicfelix for the report, and to David Sanders and Sarah
Boyce for the reviews.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36411#comment:16>

Django

unread,
Jun 3, 2025, 3:12:14 PM6/3/25
to django-...@googlegroups.com
#36411: MediaType.get_preferred_type ignores params
-------------------------------------+-------------------------------------
Reporter: magicfelix | Owner: Jake
| Howard
Type: Bug | Status: closed
Component: HTTP handling | Version: 5.2
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia <124304+nessita@…>):

In [changeset:"0c548e62d0166c559ca59845079c2b70730fcfe7" 0c548e62]:
{{{#!CommitTicketReference repository=""
revision="0c548e62d0166c559ca59845079c2b70730fcfe7"
[5.2.x] Fixed #36411 -- Made HttpRequest.get_preferred_type() consider
media type parameters.

HttpRequest.get_preferred_type() did not account for parameters in
Accept header media types (e.g., "text/vcard; version=3.0"). This caused
incorrect content negotiation when multiple types differed only by
parameters, reducing specificity as per RFC 7231 section 5.3.2
(https://datatracker.ietf.org/doc/html/rfc7231.html#section-5.3.2).

This fix updates get_preferred_type() to treat media types with
parameters as distinct, allowing more precise and standards-compliant
matching.

Thanks to magicfelix for the report, and to David Sanders and Sarah
Boyce for the reviews.

Backport of c075508b4de8edf9db553b409f8a8ed2f26ecead from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36411#comment:17>
Reply all
Reply to author
Forward
0 new messages