Browse Source

fs: add error code on null byte paths

This commit adds a code field to the error returned by
nullCheck().

Fixes: https://github.com/iojs/io.js/issues/517
PR-URL: https://github.com/iojs/io.js/pull/519
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
v1.8.0-commit
cjihrig 10 years ago
parent
commit
03ee4d8547
  1. 1
      lib/fs.js
  2. 1
      test/parallel/test-fs-null-bytes.js

1
lib/fs.js

@ -86,6 +86,7 @@ function assertEncoding(encoding) {
function nullCheck(path, callback) {
if (('' + path).indexOf('\u0000') !== -1) {
var er = new Error('Path must be a string without null bytes.');
er.code = 'ENOENT';
if (!callback)
throw er;
process.nextTick(function() {

1
test/parallel/test-fs-null-bytes.js

@ -7,6 +7,7 @@ function check(async, sync) {
var argsSync = Array.prototype.slice.call(arguments, 2);
var argsAsync = argsSync.concat(function(er) {
assert(er && er.message.match(expected));
assert.equal(er.code, 'ENOENT');
});
if (sync)

Loading…
Cancel
Save