Skip to content

Commit 7eaba8c

Browse files
author
Ruben Bridgewater
committed
Add tests to make sure no invalid function names get exported
1 parent 1487760 commit 7eaba8c

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
## v.2.6.1 - 02 Jun, 2016
5+
6+
Bugfixes
7+
8+
- Fixed invalid function name being exported
9+
410
## v.2.6.0 - 01 Jun, 2016
511

612
In addition to the pre-releases the following changes exist in v.2.6.0:

lib/commands.js

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ var changeFunctionName = (function () {
2121
// that provided a functionality to add new commands to the client
2222

2323
commands.list.forEach(function (command) {
24+
25+
// Some rare Redis commands use special characters in their command name
26+
// Convert those to a underscore to prevent using invalid function names
2427
var commandName = command.replace(/(?:^([0-9])|[^a-zA-Z0-9_$])/g, '_$1');
2528

2629
// Do not override existing functions

test/node_redis.spec.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var helper = require('./helper');
99
var utils = require('../lib/utils');
1010
var fork = require('child_process').fork;
1111
var redis = config.redis;
12+
var client;
1213

1314
describe('The node_redis client', function () {
1415

@@ -29,10 +30,18 @@ describe('The node_redis client', function () {
2930
});
3031
});
3132

33+
it('convert minus to underscore in Redis function names', function (done) {
34+
var names = Object.keys(redis.RedisClient.prototype);
35+
client = redis.createClient();
36+
for (var i = 0; i < names.length; i++) {
37+
assert(/^([a-zA-Z_][a-zA-Z_0-9]*)?$/.test(client[names[i]].name));
38+
}
39+
client.quit(done);
40+
});
41+
3242
helper.allTests(function (parser, ip, args) {
3343

3444
describe('using ' + parser + ' and ' + ip, function () {
35-
var client;
3645

3746
afterEach(function () {
3847
client.end(true);

0 commit comments

Comments
 (0)