Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Jan 15, 2025
1 parent 60dea3f commit d2841d6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
};

Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
return bidirectionalIndexOf(this, val, byteOffset, encoding) !== -1;
return bidirectionalIndexOf(this, val, byteOffset, encoding, true) !== -1;
};

// Usage:
Expand Down
7 changes: 1 addition & 6 deletions test/fixtures/permission/fs-traversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ const uint8ArrayTraversalPath = new TextEncoder().encode(traversalPath);
return w.apply(this, [traversalPath, ...args]);
})(Buffer.prototype.utf8Write);

// Sanity check (remove if the internals of Buffer.from change):
// The custom implementation of utf8Write should cause Buffer.from() to encode
// traversalPath instead of the sanitized output of resolve().
assert.strictEqual(Buffer.from(resolve(traversalPathWithExtraChars)).toString(), traversalPath);

assert.throws(() => {
fs.readFileSync(traversalPathWithExtraBytes);
}, common.expectsError({
Expand All @@ -125,4 +120,4 @@ const uint8ArrayTraversalPath = new TextEncoder().encode(traversalPath);
assert.ok(!process.permission.has('fs.write', traversalPath));
assert.ok(!process.permission.has('fs.read', traversalFolderPath));
assert.ok(!process.permission.has('fs.write', traversalFolderPath));
}
}

0 comments on commit d2841d6

Please sign in to comment.