Skip to content

Commit 9e30615

Browse files
committed
Use case-insensitive check for request conditions
This commit ensures that the ConsumesRequestCondition and ProducesRequestCondition use a case insensitive check when comparing parameters. Closes gh-29416
1 parent 481389f commit 9e30615

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractMediaTypeExpression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected boolean matchParameters(MediaType contentType) {
8585
for (Map.Entry<String, String> entry : getMediaType().getParameters().entrySet()) {
8686
if (StringUtils.hasText(entry.getValue())) {
8787
String value = contentType.getParameter(entry.getKey());
88-
if (StringUtils.hasText(value) && !entry.getValue().equals(value)) {
88+
if (StringUtils.hasText(value) && !entry.getValue().equalsIgnoreCase(value)) {
8989
return false;
9090
}
9191
}

spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ public void matchWithParameters() {
9898
condition = new ConsumesRequestCondition(base);
9999
exchange = postExchange(base + ";profile=\"a\"");
100100
assertThat(condition.getMatchingCondition(exchange)).isNotNull();
101+
102+
condition = new ConsumesRequestCondition(base + ";profile=\"a\"");
103+
exchange = postExchange(base + ";profile=\"A\"");
104+
assertThat(condition.getMatchingCondition(exchange)).isNotNull();
101105
}
102106

103107
@Test

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractMediaTypeExpression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected boolean matchParameters(MediaType contentType) {
8585
for (Map.Entry<String, String> entry : getMediaType().getParameters().entrySet()) {
8686
if (StringUtils.hasText(entry.getValue())) {
8787
String value = contentType.getParameter(entry.getKey());
88-
if (StringUtils.hasText(value) && !entry.getValue().equals(value)) {
88+
if (StringUtils.hasText(value) && !entry.getValue().equalsIgnoreCase(value)) {
8989
return false;
9090
}
9191
}

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestConditionTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ public void matchWithParameters() {
107107
condition = new ConsumesRequestCondition(base);
108108
request.setContentType(base + ";profile=\"a\"");
109109
assertThat(condition.getMatchingCondition(request)).isNotNull();
110+
111+
condition = new ConsumesRequestCondition(base + ";profile=\"a\"");
112+
request.setContentType(base + ";profile=\"A\"");
113+
assertThat(condition.getMatchingCondition(request)).isNotNull();
110114
}
111115

112116
@Test

0 commit comments

Comments
 (0)