Working null byte patch checks

This commit is contained in:
David Humphrey 2013-11-26 15:38:22 -05:00 committed by David Humphrey (:humph) david.humphrey@senecacollege.ca
parent 77f32c4c50
commit b7733a591d
3 changed files with 11 additions and 1 deletions

4
dist/idbfs.js vendored
View File

@ -8866,6 +8866,10 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
callback(new EInvalid('flags is not valid'));
}
data = data || '';
if(typeof data === "number") {
data = '' + data;
}
if(typeof data === "string" && options.encoding === 'utf8') {
data = new TextEncoder('utf-8').encode(data);
}

View File

@ -1317,6 +1317,10 @@ define(function(require) {
callback(new EInvalid('flags is not valid'));
}
data = data || '';
if(typeof data === "number") {
data = '' + data;
}
if(typeof data === "string" && options.encoding === 'utf8') {
data = new TextEncoder('utf-8').encode(data);
}

View File

@ -108,7 +108,9 @@ describe("node.js tests from https://github.com/joyent/node/blob/master/test", f
check(fs.symlink, 'foo\u0000bar', 'foobar');
check(fs.symlink, 'foobar', 'foo\u0000bar');
check(fs.unlink, 'foo\u0000bar');
check(fs.writeFile, 'foo\u0000bar');
// NOTE: the node.js test doesn't pass anything for the data arg
// but this just seems wrong based on their docs. Here I use one.
check(fs.writeFile, 'foo\u0000bar', 'foobar');
// TODO - need to be implemented still...
// check(fs.appendFile, 'foo\u0000bar');
// check(fs.realpath, 'foo\u0000bar');