Content type application/json selected incorrectly using Microsoft Edge headers #98
Description
Hi all,
This was a interesting case encountered using the Microsoft Edge (41.16299.15.0) browser, which sends the following headers by default.
Accept: text/html, application/xhtml+xml, image/jxr, */*
When the priorities are prioritised with application/json, text/html
; then the Content Negotiation will prefer the application/json
response type; this should clearly prefer text/html
based on the headers send by Edge.
I worked around the issue by changing the priority from application/json, text/html
=> text/html, application/json
. But I thought it a good idea to flag this issue.
I've written some tests which expose this behaviour, the following is the (invalid) 'passing' test.
array(
array(new Accept('text/html'), new Accept('application/xhtml+xml'), new Accept('image/jxr'), new Accept('*/*')),
array(new Accept('application/json'), new Accept('text/html')),
array(
new Match(1.0, 0, 0), // application/json
new Match(1.0, 110, 1), // text/html
new Match(1.0, 0, 1), // */*
)
)
This seems to be caused by the index, but I am not exactly sure what the correct fix would be, hense the lack of a PR. My best guess is that application/xhtml+xml should not match application/json in any way, as they are radically different.