Skip to content

Commit

Permalink
Backport PR #8758
Browse files Browse the repository at this point in the history
---------

**Commit 1:**
URI-encode forwarded location header in proxy

Right now there are situations in which ElasticSearch puts characters in
the character code range between 128 and 255 into the `Location` header.
This leads to an exception when trying to pass on that header through
the hapi proxy in versions before 15.0.0, because it validates that only
US-ASCII characters are used in headers.

To work around that situation, the `Location` header is encoded using
`encodeURI()` for now.

Closes #8705

* Original sha: 18c23c1
* Authored by Felix Stürmer <[email protected]> on 2016-10-18T17:55:31Z

**Commit 2:**
Add test to verify umlaut in vis name

Relates to #8705

* Original sha: e100e1f
* Authored by Felix Stürmer <[email protected]> on 2016-10-19T09:01:46Z

**Commit 3:**
[elasticsearch/proxy] use different code path with erorr

* Original sha: fec5e1a
* Authored by spalger <[email protected]> on 2016-10-19T19:06:39Z
  • Loading branch information
elastic-jasper committed Oct 19, 2016
1 parent 4f2ba78 commit 9c93aa6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core_plugins/elasticsearch/lib/create_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@ function createProxy(server, method, route, config) {
xforward: true,
timeout: server.config().get('elasticsearch.requestTimeout'),
onResponse: function (err, responseFromUpstream, request, reply) {
reply(err, responseFromUpstream);
if (err) {
reply(err);
return;
}

if (responseFromUpstream.headers.location) {
// TODO: Workaround for #8705 until hapi has been updated to >= 15.0.0
responseFromUpstream.headers.location = encodeURI(responseFromUpstream.headers.location);
}

reply(null, responseFromUpstream);
}
}
},
Expand Down
10 changes: 10 additions & 0 deletions test/functional/apps/visualize/_area_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ bdd.describe('visualize app', function describeIndexTests() {
});
});

bdd.it('should save and load with non-ascii characters', async function () {
const vizNamewithSpecialChars = `${vizName1} with Umlaut ä`;
const message = await PageObjects.visualize.saveVisualization(vizNamewithSpecialChars);

PageObjects.common.debug(`Saved viz message with umlaut = ${message}`);
expect(message).to.be(`Visualization Editor: Saved Visualization "${vizNamewithSpecialChars}"`);

await PageObjects.visualize.waitForToastMessageGone();
});

bdd.it('should save and load', function () {
return PageObjects.visualize.saveVisualization(vizName1)
.then(function (message) {
Expand Down

0 comments on commit 9c93aa6

Please sign in to comment.