You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During test-writing / manual fuzzing, I noticed that the doc for mkdtemp added in #6800 states that "Generates six random characters to be appended behind a required prefix to create a unique temporary directory". This is true on Linux and Windows, but misses an edge case on BSDs (including Apple). As seen below, it actually "replaces trailing X's with random characters and then appends six additional random characters to the prefix to create a unique directory name".
// on macOS
> fs.mkdtempSync(path.join(os.tmpdir(), 'foox')) // does as documented
'/tmp/fooxz5Ve7r'
> fs.mkdtempSync(path.join(os.tmpdir(), 'fooX')) // also replaces the X from the prefix
'/tmp/foo1PqEasA'
^-- not an 'X'
I think this is just a doc issue, but opening this as an issue to hear what others think.
Activity
sam-github commentedon Mar 4, 2019
@nodejs/libuv Not sure if this is a libuv issue. Its just calling
mkdtemp(), should it be shielding users from platform variations in that API?If not, node docs could say "some systems may replace trailing
'X's. Do not rely on this for portability." or something of the like.vtjnash commentedon Mar 30, 2019
Thanks for confirming and clarifying the intended behavior!
doc: add note about mkdtemp() platform differences
doc: add note about mkdtemp() platform differences
fs: warn on non-portable mkdtemp() templates