GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs,doc,test: open reserved characters under win32 by XadillaX · Pull Request #13875 · nodejs/node

Conversation

@XadillaX

@XadillaX XadillaX commented Jun 22, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Explain the behavior of fs.open() under win32 that file path contains
some characters and add some test cases for them.

  • < (less than)
  • > (greater than)
  • : (colon)
  • " (double quote)
  • / (forward slash)
  • \ (backslash)
  • | (vertical bar or pipe)
  • ? (question mark)
  • * (asterisk)

Refs: #13868
Refs: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
Refs: https://msdn.microsoft.com/en-us/library/windows/desktop/bb540537.aspx

Checklist
  • make -j4 test (UNIX)
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

fs, doc, test

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originating in Node.js core. fs Issues and PRs related to file-system APIs and the fs module. labels Jun 22, 2017
mscdex
mscdex reviewed Jun 22, 2017
View reviewed changes
Comment thread lib/fs.js Outdated

@mscdex mscdex Jun 22, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this extra closure is needed. Perhaps it could just be process.nextTick(req.oncomplete, err).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@XadillaX XadillaX Jun 22, 2017

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mscdex sometimes req.oncomplete depends on req, eg.

  var context = new ReadFileContext(callback, options.encoding);
  context.isUserFd = isFd(path); // file descriptor ownership
  var req = new FSReqWrap();
  req.context = context;
  req.oncomplete = readFileAfterOpen;

...

function readFileAfterOpen(err, fd) {
  var context = this.context;

  ...
}

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mscdex mscdex Jun 22, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Perhaps we could at least factor out the callback then, like:

process.nextTick(onWinOpenErrorNT, req, err);

// ...

function onWinOpenErrorNT(req, err) {
  req.oncomplete(err);
}

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

XadillaX reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@mscdex

mscdex commented Jun 22, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I wonder if having two separate implementations, one for posix and one for Windows, would help any performance-wise? I think it definitely would on node v6.x, which still uses Crankshaft and would possibly allow the posix version to be inlineable.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@XadillaX

XadillaX commented Jun 22, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@mscdex Now only one call stack is added, and an if statement added. I think it won't slow down too much.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mscdex
mscdex reviewed Jun 22, 2017
View reviewed changes
Comment thread lib/fs.js Outdated

@mscdex mscdex Jun 22, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to start explicitly checking for these, perhaps we should be checking for all of the reserved characters, either here in JS or at the libuv layer (via a flag of some kind if not enforced all the time for Windows).

EDIT: I just saw your comment about the other reserved characters. I'm wondering if we actually test for those on Windows nodes in CI...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@silverwind

silverwind commented Jun 22, 2017

Copy link
Copy Markdown
Contributor

Did you test other invalid characters and/or filenames (like com, prn)? Windows has quite peculiar rules on which filenames are considered valid, ideally I think we should test them all:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#Naming_Conventions

refack reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@XadillaX

XadillaX commented Jun 22, 2017

Copy link
Copy Markdown
Contributor Author

Did you test other invalid characters and/or filenames (like com, prn)? Windows has quite peculiar rules on which filenames are considered valid, ideally I think we should test them all:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#Naming_Conventions

Not yet. image

I will try it tomorrow, now it's 1:11 a.m. at my location and I'm going to sleep.

refack reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@XadillaX

XadillaX commented Jun 23, 2017

Copy link
Copy Markdown
Contributor Author

@mscdex @silverwind Sorry, I'm going to take a vacation for one week and now I don't have a Windows computer at my hand. So maybe I will continue to work for this PR after one week.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cjihrig
cjihrig reviewed Jun 23, 2017
View reviewed changes
Comment thread lib/fs.js Outdated

@cjihrig cjihrig Jun 23, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the stringToFlags() calls should be pushed into openWrap() too.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cjihrig
cjihrig reviewed Jun 23, 2017
View reviewed changes
Comment thread lib/fs.js Outdated

@cjihrig cjihrig Jun 23, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: single line if statements shouldn't have curly braces.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cjihrig
cjihrig reviewed Jun 23, 2017
View reviewed changes
Comment thread lib/internal/errors.js Outdated

@cjihrig cjihrig Jun 23, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the errors in this file are sorted by error code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cjihrig
cjihrig reviewed Jun 23, 2017
View reviewed changes
Comment thread test/parallel/test-fs-write-file-invalid-path.js Outdated

@cjihrig cjihrig Jun 23, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you have to add this for new files.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cjihrig
cjihrig reviewed Jun 23, 2017
View reviewed changes
Comment thread test/parallel/test-fs-write-file-invalid-path.js Outdated

@cjihrig cjihrig Jun 23, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use common.skip() here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cjihrig
cjihrig reviewed Jun 23, 2017
View reviewed changes
Comment thread test/parallel/test-fs-write-file-invalid-path.js Outdated

@cjihrig cjihrig Jun 23, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add common.mustCall() to the readFile() and writeFile() callbacks in this file.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cjihrig
cjihrig reviewed Jun 23, 2017
View reviewed changes
Comment thread test/parallel/test-fs-write-file-invalid-path.js Outdated

@cjihrig cjihrig Jun 23, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use ^ and $ to match the full error message.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@silverwind

silverwind commented Jun 23, 2017

Copy link
Copy Markdown
Contributor

I agree with @mscdex, if we do this checking, it's better done in libuv.

Of course, it's also possible to delegate the task of checking if a filename is valid for a platform to the user, for example through modules like https://github.com/sindresorhus/valid-filename.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@XadillaX

XadillaX commented Jun 24, 2017

Copy link
Copy Markdown
Contributor Author

@silverwind To be honest, I think libuv's PR progress is much slower than Node.js'.

I will continue to work for other reserved names by implement a checking function next week after my vacation.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@refack

refack commented Jun 24, 2017

Copy link
Copy Markdown
Contributor

I will continue to work for other reserved names by implement a checking function next week after my vacation.

Enjoy 🍹

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bzoz

bzoz commented Jun 27, 2017

Copy link
Copy Markdown
Contributor

This file:smth is an NTFS feature, using > etc in filenames is already correctly handled by Node. Please see my comment in the original issue..

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bzoz

bzoz commented Jun 27, 2017

Copy link
Copy Markdown
Contributor

Oh, forgot to add that I'm -1 on this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@refack

refack commented Jun 27, 2017

Copy link
Copy Markdown
Contributor

Oh, forgot to add that I'm -1 on this.

@bzoz It has an element of surprise (alternative streams I personally keep forgetting about). Should we at least document this? Or maybe add special syntax for?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bzoz

bzoz commented Jun 27, 2017

Copy link
Copy Markdown
Contributor

IMHO we should document this. Special syntax would be surprising for everyone that already knows this feature. It would also add maintenance burden.

refack reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@XadillaX

XadillaX commented Jun 27, 2017

Copy link
Copy Markdown
Contributor Author

@bzoz so what I should do is just to document it?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bzoz

bzoz commented Jun 27, 2017

Copy link
Copy Markdown
Contributor

I guess so.

The streams feature of NTFS is surprising, we can mention it in the docs and add a link to MSDN: https://msdn.microsoft.com/en-us/library/windows/desktop/bb540537.aspx

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@XadillaX

XadillaX commented Jun 27, 2017

Copy link
Copy Markdown
Contributor Author

I'll update this issue to document this feature after I'm back.

bzoz and silverwind reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@XadillaX
XadillaX force-pushed the fix/fs-colon-in-path-under-windows branch from 9498ec8 to e90f5cb Compare July 3, 2017 09:10
@XadillaX XadillaX changed the title fs: fs.write wrong behavior under win32 fs,doc,test: open reserved characters under win32 Jul 3, 2017
@XadillaX

XadillaX commented Jul 3, 2017

Copy link
Copy Markdown
Contributor Author

@cjihrig, @refack, @bzoz, I've updated this PR to explain the behavior.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@XadillaX
XadillaX force-pushed the fix/fs-colon-in-path-under-windows branch from 86dc587 to c1c5d57 Compare July 3, 2017 09:43
This was referenced Sep 15, 2021
[Snyk] Fix for 1 vulnerabilities Dmarch28/node#37
Open
[Snyk] Fix for 1 vulnerabilities baby636/node#23
Open
[Snyk] Security upgrade eslint from 6.8.0 to 7.16.0 baby636/node#24
Open
[Snyk] Security upgrade eslint from 5.16.0 to 7.16.0 Zintexiss/node-22#62
Open
[Snyk] Security upgrade eslint from 5.16.0 to 7.16.0 Zintexiss/node-22#63
Open
[Snyk] Fix for 1 vulnerabilities ron-a20/node#45
Open
[Snyk] Fix for 1 vulnerabilities Rednickle/node-1#32
Open
[Snyk] Fix for 1 vulnerabilities meghasfdc/node#46
Open
[Snyk] Fix for 1 vulnerabilities aliceUnhinged613/node#36
Open
[Snyk] Security upgrade eslint from 5.16.0 to 7.16.0 baby636/node#25
Open
[Snyk] Fix for 1 vulnerabilities Zintexiss/node-22#64
Open
[Snyk] Fix for 1 vulnerabilities baby636/node#26
Open
[Snyk] Fix for 1 vulnerabilities ryan-ally/node#41
Open
[Snyk] Fix for 1 vulnerabilities 137717unity/node#38
Open
[Snyk] Fix for 1 vulnerabilities wedataintelligence/node#14
Open
[Snyk] Fix for 1 vulnerabilities kissofire/node#47
Open
[Snyk] Fix for 1 vulnerabilities ryan-ally/node#42
Open
[Snyk] Security upgrade eslint from 5.16.0 to 7.16.0 Zintexiss/node-22#65
Open
[Snyk] Security upgrade eslint from 5.16.0 to 7.16.0 ryan-ally/node#43
Open
[Snyk] Security upgrade eslint from 5.16.0 to 7.16.0 ryan-ally/node#44
Open
[Snyk] Fix for 1 vulnerabilities sitedata/node#37
Open
[Snyk] Security upgrade eslint from 6.8.0 to 7.16.0 ryan-ally/node#45
Open
[Snyk] Security upgrade eslint from 5.16.0 to 7.16.0 ryan-ally/node#46
Open
[Snyk] Security upgrade eslint from 6.8.0 to 7.16.0 Mement-Mori/node#12
Open
[Snyk] Security upgrade eslint from 6.8.0 to 7.16.0 MaxMood96/node#13
Open
[Snyk] Security upgrade eslint from 5.16.0 to 7.16.0 baby636/node#27
Open
[Snyk] Fix for 1 vulnerabilities molllyn1/node#27
Open
@snyk-bot snyk-bot mentioned this pull request Feb 12, 2022
[Snyk] Fix for 9 vulnerabilities Iceymann18777/node#10
Open
@coderabbitai coderabbitai Bot mentioned this pull request Aug 11, 2026
fix(installer): make Windows setup launch the UI oscharko-dev/Keiko#3075
Merged
@Domiii Domiii mentioned this pull request Nov 17, 2026
Pin the backend to master with the linker scan-memory stack replayio/node#237
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cjihrig cjihrig cjihrig approved these changes
@tniessen tniessen tniessen approved these changes
+5 more reviewers
@mscdex mscdex mscdex left review comments
@refack refack refack approved these changes
@silverwind silverwind silverwind approved these changes
@vsemozhetbyt vsemozhetbyt vsemozhetbyt approved these changes
@bzoz bzoz bzoz approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

errors Issues and PRs related to JavaScript errors originating in Node.js core. fs Issues and PRs related to file-system APIs and the fs module.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@XadillaX @mscdex @silverwind @refack @bzoz @cjihrig @tniessen @vsemozhetbyt @MylesBorins @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.