Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#394 #395

Merged
merged 3 commits into from
Mar 26, 2018
Merged

#394 #395

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ All notable changes to Knot.x will be documented in this file.

## Unreleased
List of changes that are finished but not yet released in any final version.
- [PR-395](https://github.com/Cognifide/knotx/pull/395) - Fix for [#394](https://github.com/Cognifide/knotx/issues/394) - implemented encoding request parameter names in `HttpRepositoryConnectorProxyImpl`

## Version 1.2.1
- [PR-385](https://github.com/Cognifide/knotx/pull/385) - Fix for [#107](https://github.com/Cognifide/knotx/pull/107) - Support for snippet tags other than `script`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
public class SampleApplicationTest {

private static final String REMOTE_REQUEST_URI = "/content/remote/simple.html";
private static final String REMOTE_REQUEST_URI_WITH_PARAMETER_CONTAINING_SPACE = "/content/remote/simple.html?parameter%20with%20space=value";
private static final String LOCAL_REQUEST_URI = "/content/local/simple.html";
private static final String MISSING_SERVICE_CONFIG_REQUEST_URI = "/content/local/missingServiceConfig.html";
private static final String LOCAL_NO_BODY_REQUEST_URI = "/content/local/noBody.html";
Expand Down Expand Up @@ -96,6 +97,12 @@ public void whenRequestingRemoteSimplePageWithGet_expectRemoteSimpleHtml(TestCon
testGetRequest(context, REMOTE_REQUEST_URI, "remoteSimpleResult.html");
}

@Test
@KnotxConfiguration("knotx-test-app.json")
public void whenRequestingRemoteSimplePageWithGetAndRequestParameterNameContainsSpace_expectRemoteSimpleHtml(TestContext context) {
testGetRequest(context, REMOTE_REQUEST_URI_WITH_PARAMETER_CONTAINING_SPACE, "remoteSimpleResult.html");
}

@Test
@KnotxConfiguration("knotx-test-app.json")
public void whenRequestingLocalMultipleFormsPageWithGet_expectMutlipleFormsWithGetResultHtml(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void process(ClientRequest request, Handler<AsyncResult<ClientResponse>>

private RequestOptions buildRequestData(ClientRequest request) {
return new RequestOptions()
.setSsl(clientDestination.getString("scheme", "http").equals("https") ? true : false)
.setSsl(clientDestination.getString("scheme", "http").equals("https"))
.setURI(buildRepoUri(request))
.setPort(clientDestination.getInteger("port"))
.setHost(clientDestination.getString("domain"));
Expand Down Expand Up @@ -138,16 +138,16 @@ private String buildRepoUri(ClientRequest repoRequest) {
if (params != null && params.names() != null && !params.names().isEmpty()) {
uri.append("?")
.append(params.names().stream()
.map(name -> new StringBuilder(name).append("=")
.append(encodeParamValue(params.get(name))))
.map(name -> new StringBuilder(encode(name)).append("=")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write the Unit test for this case.

Copy link
Contributor

@rkarwacki rkarwacki Mar 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test added, as a part of SampleApplicationTest.

.append(encode(params.get(name))))
.collect(Collectors.joining("&"))
);
}

return uri.toString();
}

private String encodeParamValue(String value) {
private String encode(String value) {
try {
return URLEncoder.encode(value, "UTF-8").replace("+", "%20").replace("%2F", "/");
} catch (UnsupportedEncodingException ex) {
Expand Down