Long ago I added a spec-compliant version of the Mime-type parsing, in bug 1454325. It has been in-use long enough now for some other cases that I think we should now consider just using it instead of net_ParseContentType. This will let us pass some WPTs. Also, Safari has been using a spec-compliant parser as well, so the webcompat risk should be fairly low.
Bug 1845006 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Basically, we already parse the mime type part of the URL here: https://searchfox.org/mozilla-central/source/netwerk/protocol/data/nsDataChannel.cpp#61 But SetContentType and SetContentCharset at the end of the function will also re-parse the result, using our older parser which isn't saving the parameters of the mime type: https://searchfox.org/mozilla-central/source/netwerk/protocol/data/nsDataChannel.cpp#102-103 We should just set mContentType and Charset in the first line above. Per spec we should also be serializing the full resulting mimetype here, not just getting its essence: https://searchfox.org/mozilla-central/source/netwerk/protocol/data/nsDataHandler.cpp#189 Finally, the fetch and XHR code doubles-up the charset needlessly in these spots, so we should tell it to only add the charset if it's not already present: - https://searchfox.org/mozilla-central/source/dom/fetch/FetchDriver.cpp#1063-1069 - https://searchfox.org/mozilla-central/source/dom/xhr/XMLHttpRequestMainThread.cpp#1157-1165 - https://searchfox.org/mozilla-central/source/dom/xhr/XMLHttpRequestMainThread.cpp#1216-1222 With these changes we'll pass
Basically, we already parse the mime type part of the URL here: https://searchfox.org/mozilla-central/source/netwerk/protocol/data/nsDataChannel.cpp#61 But SetContentType and SetContentCharset at the end of the function will also re-parse the result, using our older parser which isn't saving the parameters of the mime type: https://searchfox.org/mozilla-central/source/netwerk/protocol/data/nsDataChannel.cpp#102-103 We should just set mContentType and Charset in the first line above. Per spec we should also be serializing the full resulting mimetype here, not just getting its essence: https://searchfox.org/mozilla-central/source/netwerk/protocol/data/nsDataHandler.cpp#189 Finally, the fetch and XHR code doubles-up the charset needlessly in these spots, so we should tell it to only add the charset if it's not already present: - https://searchfox.org/mozilla-central/source/dom/fetch/FetchDriver.cpp#1063-1069 - https://searchfox.org/mozilla-central/source/dom/xhr/XMLHttpRequestMainThread.cpp#1157-1165 - https://searchfox.org/mozilla-central/source/dom/xhr/XMLHttpRequestMainThread.cpp#1216-1222
Basically, we already parse the mime type part of the URL here: https://searchfox.org/mozilla-central/source/netwerk/protocol/data/nsDataChannel.cpp#61 But SetContentType and SetContentCharset at the end of the function will also re-parse the result, using our older parser which isn't saving the parameters of the mime type: https://searchfox.org/mozilla-central/source/netwerk/protocol/data/nsDataChannel.cpp#102-103 We should just set mContentType and mContentCharset in the first line above. Per spec we should also be serializing the full resulting mimetype here, not just getting its essence: https://searchfox.org/mozilla-central/source/netwerk/protocol/data/nsDataHandler.cpp#189 Finally, the fetch and XHR code doubles-up the charset needlessly in these spots, so we should tell it to only add the charset if it's not already present: - https://searchfox.org/mozilla-central/source/dom/fetch/FetchDriver.cpp#1063-1069 - https://searchfox.org/mozilla-central/source/dom/xhr/XMLHttpRequestMainThread.cpp#1157-1165 - https://searchfox.org/mozilla-central/source/dom/xhr/XMLHttpRequestMainThread.cpp#1216-1222