[connectors/http] prevent errors caused by multi-byte characters in paths (#756)
* [connectors/http] catch errors caused by multi-byte paths * Check url validity before to run the request * Updated test
This commit is contained in:
@ -19,6 +19,7 @@ var qs = require('querystring');
|
||||
var AgentKeepAlive = require('agentkeepalive');
|
||||
var ConnectionAbstract = require('../connection');
|
||||
var zlib = require('zlib');
|
||||
var INVALID_PATH_REGEX = /[^\u0021-\u00ff]/
|
||||
|
||||
/**
|
||||
* Connector used to talk to an elasticsearch node via HTTP
|
||||
@ -166,6 +167,11 @@ HttpConnector.prototype.request = function (params, cb) {
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (INVALID_PATH_REGEX.test(reqParams.path) === true) {
|
||||
cb(new TypeError('ERR_UNESCAPED_CHARACTERS: ' + reqParams.path))
|
||||
return function () {}
|
||||
}
|
||||
|
||||
request = this.hand.request(reqParams, function (_incoming) {
|
||||
incoming = _incoming;
|
||||
status = incoming.statusCode;
|
||||
|
||||
Reference in New Issue
Block a user