Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e8fffeb

Browse filesBrowse files
RafaelGSStargos
authored andcommitted
fs,test: add URL to string to fs.watch
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: #51346 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent e942dc1 commit e8fffeb
Copy full SHA for e8fffeb

File tree

Expand file treeCollapse file tree

2 files changed

+9
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-3
lines changed
Open diff view settings
Collapse file

‎lib/fs.js‎

Copy file name to clipboardExpand all lines: lib/fs.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ const {
108108
getValidatedPath,
109109
getValidMode,
110110
handleErrorFromBinding,
111-
possiblyTransformPath,
112111
preprocessSymlinkDestination,
113112
Stats,
114113
getStatFsFromBinding,
@@ -2451,7 +2450,7 @@ function watch(filename, options, listener) {
24512450

24522451
let watcher;
24532452
const watchers = require('internal/fs/watchers');
2454-
const path = possiblyTransformPath(filename);
2453+
const path = getValidatedPath(filename);
24552454
// TODO(anonrig): Remove non-native watcher when/if libuv supports recursive.
24562455
// As of November 2022, libuv does not support recursive file watch on all platforms,
24572456
// e.g. Linux due to the limitations of inotify.
Collapse file

‎test/fixtures/permission/fs-read.js‎

Copy file name to clipboardExpand all lines: test/fixtures/permission/fs-read.js
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ const regularFile = __filename;
265265
permission: 'FileSystemRead',
266266
resource: path.toNamespacedPath(blockedFile),
267267
}));
268+
assert.throws(() => {
269+
fs.watch(blockedFileURL, () => {});
270+
}, common.expectsError({
271+
code: 'ERR_ACCESS_DENIED',
272+
permission: 'FileSystemRead',
273+
resource: path.toNamespacedPath(blockedFile),
274+
}));
268275

269276
// doesNotThrow
270277
fs.readdir(allowedFolder, (err) => {
@@ -353,4 +360,4 @@ const regularFile = __filename;
353360
permission: 'FileSystemRead',
354361
resource: path.toNamespacedPath(blockedFile),
355362
}));
356-
}
363+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.