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
This commit is contained in:
@@ -85,7 +85,7 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
|
||||
for (Map.Entry<String, String> entry : getMediaType().getParameters().entrySet()) {
|
||||
if (StringUtils.hasText(entry.getValue())) {
|
||||
String value = contentType.getParameter(entry.getKey());
|
||||
if (StringUtils.hasText(value) && !entry.getValue().equals(value)) {
|
||||
if (StringUtils.hasText(value) && !entry.getValue().equalsIgnoreCase(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,10 @@ public class ConsumesRequestConditionTests {
|
||||
condition = new ConsumesRequestCondition(base);
|
||||
exchange = postExchange(base + ";profile=\"a\"");
|
||||
assertThat(condition.getMatchingCondition(exchange)).isNotNull();
|
||||
|
||||
condition = new ConsumesRequestCondition(base + ";profile=\"a\"");
|
||||
exchange = postExchange(base + ";profile=\"A\"");
|
||||
assertThat(condition.getMatchingCondition(exchange)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -85,7 +85,7 @@ abstract class AbstractMediaTypeExpression implements MediaTypeExpression, Compa
|
||||
for (Map.Entry<String, String> entry : getMediaType().getParameters().entrySet()) {
|
||||
if (StringUtils.hasText(entry.getValue())) {
|
||||
String value = contentType.getParameter(entry.getKey());
|
||||
if (StringUtils.hasText(value) && !entry.getValue().equals(value)) {
|
||||
if (StringUtils.hasText(value) && !entry.getValue().equalsIgnoreCase(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,10 @@ public class ConsumesRequestConditionTests {
|
||||
condition = new ConsumesRequestCondition(base);
|
||||
request.setContentType(base + ";profile=\"a\"");
|
||||
assertThat(condition.getMatchingCondition(request)).isNotNull();
|
||||
|
||||
condition = new ConsumesRequestCondition(base + ";profile=\"a\"");
|
||||
request.setContentType(base + ";profile=\"A\"");
|
||||
assertThat(condition.getMatchingCondition(request)).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user