Browse Source

UriComponents allows "+" in a query param

Issue: SPR-14828
pull/1288/merge
Rossen Stoyanchev 8 years ago
parent
commit
f2e293aadf
  1. 2
      spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java
  2. 10
      spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java

2
spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java

@ -554,7 +554,7 @@ final class HierarchicalUriComponents extends UriComponents { @@ -554,7 +554,7 @@ final class HierarchicalUriComponents extends UriComponents {
QUERY_PARAM {
@Override
public boolean isAllowed(int c) {
if ('=' == c || '+' == c || '&' == c) {
if ('=' == c || '&' == c) {
return false;
}
else {

10
spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -189,6 +189,14 @@ public class UriComponentsBuilderTests { @@ -189,6 +189,14 @@ public class UriComponentsBuilderTests {
assertEquals("1USD=?EUR", result.getQueryParams().getFirst("q"));
}
@Test // SPR-14828
public void fromUriStringQueryParamEncodedAndContainingPlus() throws Exception {
String httpUrl = "http://localhost:8080/test/print?value=%EA%B0%80+%EB%82%98";
URI uri = UriComponentsBuilder.fromHttpUrl(httpUrl).build(true).toUri();
assertEquals(httpUrl, uri.toString());
}
@Test // SPR-10779
public void fromHttpUrlStringCaseInsesitiveScheme() {
assertEquals("http", UriComponentsBuilder.fromHttpUrl("HTTP://www.google.com").build().getScheme());

Loading…
Cancel
Save