Skip to content

Commit 4f3ab58

Browse files
committed
lib: better regexp escape
1 parent 23ee63a commit 4f3ab58

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

Diff for: lib/caine/contributing.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,15 @@ Contributing.prototype.parseQuestion = function parseQuestion(text) {
210210
if (match !== null) {
211211
if (/one/i.test(match[1])) {
212212
var oneof = match[2].split(/\s*,\s*/g);
213-
expected = new RegExp('^\\s*(' + oneof.join('|') + ')\\s*$', 'i');
213+
214+
var subre = oneof.map(function(part) {
215+
return part.replace(/([^\w\d_])/g, '\\$1');
216+
}).join('|');
217+
expected = new RegExp('^\\s*(' + subre + ')\\s*$', 'i');
214218
reason = 'Expected one of: `' + oneof.join('`, `') + '`, but got: `@1`';
215219
} else {
216-
expected = new RegExp('^\\s*(' + match[2] + ')\\s*$', 'i');
220+
var subre = match[2].replace(/([^\w\d_])/g, '\\$1');
221+
expected = new RegExp('^\\s*(' + subre + ')\\s*$', 'i');
217222
reason = 'Expected: `' + match[2] + '`, but got: `@1`';
218223
}
219224
}

Diff for: test/contributing-test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ describe('Contributing', function() {
118118
'Expected: `yes`, but got: `wait, what`');
119119
assert.equal(res.results[1].reason,
120120
'Expected one of: `tls`, `crypto`, `buffer`, `http`, ' +
121-
'`https`, `assert`, `util`, `streams`, `other`, ' +
121+
'`https`, `assert`, `util`, `streams`, `smalloc`, ' +
122+
'`cluster`, `child_process`, `dgram`, `c++`, `other`, ' +
122123
'but got: `everything`');
123124
assert.equal(res.results[2].reason,
124125
'Expected one of: `v0.10`, `v0.12`, `v1.0.0`, ' +

Diff for: test/fixtures/CONTRIBUTING.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ core team members?
446446
likely not a io.js problem. _Expected: `yes`_
447447
* Which part of core do you think it might be related to?
448448
_One of: `tls, crypto, buffer, http, https, assert, util, streams,
449-
other`_ (_label_)
449+
smalloc, cluster, child_process, dgram, c++, other`_ (_label_)
450450
* Which versions of io.js do you think are affected by this?
451451
_One of: `v0.10, v0.12, v1.0.0`_ (_label_)
452452
* _PR-only_ Does `make test` pass after applying this Pull Request.
@@ -474,7 +474,6 @@ Caine.
474474

475475
### Responsibilities
476476

477-
* indutny: crypto
478-
* trevnorris: buffer
479-
* isaacs: streams
480-
* bnoordhuis: other
477+
* indutny: crypto, tls, https, child_process, c++
478+
* trevnorris: buffer, http, https, smalloc
479+
* bnoordhuis: http, cluster, child_process, dgram

0 commit comments

Comments
 (0)