mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-24 07:39:09 +00:00
Merge branch '7.0.x'
This commit is contained in:
@@ -187,7 +187,7 @@ public abstract class MimeTypeUtils {
|
||||
|
||||
/**
|
||||
* Parse the given String into a single {@code MimeType}.
|
||||
* Recently parsed {@code MimeType} are cached for further retrieval.
|
||||
* <p>Recently parsed {@code MimeType} values are cached for future retrieval.
|
||||
* @param mimeType the string to parse
|
||||
* @return the mime type
|
||||
* @throws InvalidMimeTypeException if the string cannot be parsed
|
||||
@@ -238,7 +238,7 @@ public abstract class MimeTypeUtils {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ch == '"' && mimeType.charAt(nextIndex - 1) != '\\') {
|
||||
else if (ch == '"' && (nextIndex == 0 || mimeType.charAt(nextIndex - 1) != '\\')) {
|
||||
quoted = !quoted;
|
||||
}
|
||||
nextIndex++;
|
||||
|
||||
@@ -108,7 +108,7 @@ class MimeTypeTests {
|
||||
assertThat(mimeType.getParameter("type")).isEqualTo("\"application/soap+xml;action=\\\"https://x.y.z\\\"\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // gh-36730
|
||||
void parseParameterWithQuotedPair() {
|
||||
String s = "text/plain;twelve=\"1\\\"2\"";
|
||||
MimeType mimeType = MimeType.valueOf(s);
|
||||
@@ -303,6 +303,13 @@ class MimeTypeTests {
|
||||
MimeTypeUtils.parseMimeType("audio/*;attr=\""));
|
||||
}
|
||||
|
||||
@Test // gh-36971
|
||||
void parseMimeTypeWrappedInQuotes() {
|
||||
assertThatExceptionOfType(InvalidMimeTypeException.class)
|
||||
.isThrownBy(() -> MimeTypeUtils.parseMimeType("\"application/xml\""))
|
||||
.withMessageContaining("Invalid token character '\"'");
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseMimeTypeNull() {
|
||||
assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() ->
|
||||
|
||||
Reference in New Issue
Block a user