Merge branch '5.1.x'
This commit is contained in:
@@ -44,6 +44,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Dimitrios Liapis
|
||||
* @author Brian Clozel
|
||||
* @author Sam Brannen
|
||||
* @since 4.0
|
||||
*/
|
||||
public abstract class MimeTypeUtils {
|
||||
@@ -273,10 +274,11 @@ public abstract class MimeTypeUtils {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return tokenize(mimeTypes).stream()
|
||||
.map(MimeTypeUtils::parseMimeType).collect(Collectors.toList());
|
||||
.filter(StringUtils::hasText)
|
||||
.map(MimeTypeUtils::parseMimeType)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tokenize the given comma-separated string of {@code MimeType} objects
|
||||
* into a {@code List<String>}. Unlike simple tokenization by ",", this
|
||||
|
||||
@@ -303,6 +303,13 @@ public class MimeTypeTests {
|
||||
assertThat(mimeTypes.size()).as("Invalid amount of mime types").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test // gh-23241
|
||||
public void parseMimeTypesWithTrailingComma() {
|
||||
List<MimeType> mimeTypes = MimeTypeUtils.parseMimeTypes("text/plain, text/html,");
|
||||
assertThat(mimeTypes).as("No mime types returned").isNotNull();
|
||||
assertThat(mimeTypes.size()).as("Incorrect number of mime types").isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test // SPR-17459
|
||||
public void parseMimeTypesWithQuotedParameters() {
|
||||
testWithQuotedParameters("foo/bar;param=\",\"");
|
||||
|
||||
Reference in New Issue
Block a user