Allows dash characters in subdomains #47
@@ -134,7 +134,7 @@ function maybe_bounce(req, res, sock, head) {
|
|||||||
var client_req = http.request(opt, function(client_res) {
|
var client_req = http.request(opt, function(client_res) {
|
||||||
// write response code and headers
|
// write response code and headers
|
||||||
res.writeHead(client_res.statusCode, client_res.headers);
|
res.writeHead(client_res.statusCode, client_res.headers);
|
||||||
|
|
||||||
client_res.pipe(res);
|
client_res.pipe(res);
|
||||||
on_finished(client_res, function(err) {
|
on_finished(client_res, function(err) {
|
||||||
done();
|
done();
|
||||||
@@ -221,7 +221,7 @@ module.exports = function(opt) {
|
|||||||
var req_id = req.params.req_id;
|
var req_id = req.params.req_id;
|
||||||
|
|
||||||
// limit requested hostnames to 63 characters
|
// limit requested hostnames to 63 characters
|
||||||
if (! /^[a-z0-9]{4,63}$/.test(req_id)) {
|
if (! /^(?:[a-z0-9][a-z0-9\-]{4,63}[a-z0-9]|[a-z0-9]{4,63})$/.test(req_id)) {
|
||||||
var err = new Error('Invalid subdomain. Subdomains must be lowercase and between 4 and 63 alphanumeric characters.');
|
var err = new Error('Invalid subdomain. Subdomains must be lowercase and between 4 and 63 alphanumeric characters.');
|
||||||
err.statusCode = 403;
|
err.statusCode = 403;
|
||||||
return next(err);
|
return next(err);
|
||||||
|
|||||||
@@ -118,6 +118,21 @@ test('request specific domain', function(done) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('request domain with dash', function(done) {
|
||||||
|
var opt = {
|
||||||
|
host: 'http://localhost:' + lt_server_port,
|
||||||
|
subdomain: 'abcd-1234'
|
||||||
|
};
|
||||||
|
|
||||||
|
localtunnel(test._fake_port, opt, function(err, tunnel) {
|
||||||
|
assert.ifError(err);
|
||||||
|
var url = tunnel.url;
|
||||||
|
assert.ok(new RegExp('^http:\/\/.*localhost:' + lt_server_port + '$').test(url));
|
||||||
|
test._fake_url = url;
|
||||||
|
done(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('request domain that is too long', function(done) {
|
test('request domain that is too long', function(done) {
|
||||||
var opt = {
|
var opt = {
|
||||||
host: 'http://localhost:' + lt_server_port,
|
host: 'http://localhost:' + lt_server_port,
|
||||||
|
|||||||
Reference in New Issue
Block a user