Uses Charset instead of String in MimeType.equals()

Prior to this commit, Spring's MimeType checked for equality between
two MIME types based on the equality of their properties maps; however,
the properties maps contain string representations of the "charset"
values. Thus, "UTF-8" is never equal to "utf-8" which breaks the
contract for character set names which must be compared in a
case-insensitive manner.

This commit addresses this issue by ensuring that "charset" properties
in MimeType instances are compared as Java Charset instances, thereby
ignoring case when checking for equality between charset names.

Issue: SPR-13157
This commit is contained in:
Sam Brannen
2015-06-23 22:30:25 +02:00
parent f2f58f1677
commit 89e504c2f1
3 changed files with 61 additions and 14 deletions

View File

@@ -56,7 +56,7 @@ public class AbstractJettyServerTestCase {
protected static final String baseUrl = "http://localhost:" + port;
protected static final MediaType textContentType = new MediaType("text", "plain", Collections.singletonMap("charset", "utf-8"));
protected static final MediaType textContentType = new MediaType("text", "plain", Collections.singletonMap("charset", "UTF-8"));
protected static final MediaType jsonContentType = new MediaType("application", "json", Collections.singletonMap("charset", "utf-8"));