Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmpNameSync: Bad result if the TMP/TEMP env. variables are enclosed in quotes #246

Closed
7 tasks
haneefdm opened this issue Feb 27, 2020 · 4 comments · Fixed by #234 · May be fixed by mike-north/devcert#45 or sekikn/avro#9
Closed
7 tasks

tmpNameSync: Bad result if the TMP/TEMP env. variables are enclosed in quotes #246

haneefdm opened this issue Feb 27, 2020 · 4 comments · Fixed by #234 · May be fixed by mike-north/devcert#45 or sekikn/avro#9
Assignees
Labels

Comments

@haneefdm
Copy link

Operating System

  • Linux
  • Windows 7
  • [ x] Windows 10
  • MacOS
  • other:

NodeJS Version

  • 0.x
  • 4.x
  • 6.x
  • 7.x
  • other: 10.16.2

Tmp Version

TBD:0.1.0

Expected Behavior

TBD: What have you expected tmp to do?

Create proper tmp-name without quotes

Experienced Behavior

TBD: What did actually happen?

Created path names with embedded quotes if the env. vars TMP and TEMP has spaces in it. I have a space in my user name and we have to use our own TMP directories rather than using the system ones. To reproduce the problem in a shell/cmd set the TMP/TEMP variables to any path with spaces in it

set TMP="C:\users\xxx\T M P"
set TEMP="C:\users\xxx\T M P"
node test.js

The above commands creates the following output. Yes, I can filter the path-name but it was unexpected

Created temporary filename:  "C:\Users\hdm\T M P"\tmp-4832vNUYEwQFRehF

And my test.js looks like

var tmp = require('tmp');
var options = {};
var tmpname = tmp.tmpNameSync(options);
console.log('Created temporary filename: ', tmpname);
@silkentrance silkentrance changed the title tmpNameSync: Bad result if the TMP/TEMP env. variables have spaces in pathname tmpNameSync: Bad result if the TMP/TEMP env. variables are enclosed in quotes Mar 5, 2020
@silkentrance silkentrance self-assigned this Apr 8, 2020
@silkentrance silkentrance linked a pull request Apr 8, 2020 that will close this issue
15 tasks
silkentrance added a commit that referenced this issue Apr 8, 2020
…so sanitize dir option and template option
@silkentrance
Copy link
Collaborator

silkentrance commented Apr 8, 2020

This also applies to the dir option, the template option and the name option.

silkentrance added a commit that referenced this issue Apr 8, 2020
…so sanitize dir option, the template option and the name option
@silkentrance
Copy link
Collaborator

silkentrance commented Apr 8, 2020

The downside of this is that the user may no longer include a single single quote or a single double quote in the path. But this seems to be a rather fringe use case to me, so we will not support it any more.

@haneefdm
Copy link
Author

haneefdm commented Apr 8, 2020

Please, please don't make any changes; I was WRONG. Quotes are part of the string I suppose.

Microsoft Windows [Version 10.0.18362.535]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\hdm>set BLAH="a b c"

C:\Users\hdm>echo %BLAH%
"a b c"

C:\Users\hdm>set BLAH=a b c

C:\Users\hdm>echo %BLAH%
a b c

I am so so sorry to report this issue and wasted your time.

@haneefdm haneefdm closed this as completed Apr 8, 2020
@silkentrance
Copy link
Collaborator

Way too late 😄. This has already been merged and I think that it is ok handling this rather fringe case. The user might also be passing in a string for template or name or dir that might contain single quotes or double quotes.

mbargiel added a commit to mbargiel/node-tmp that referenced this issue Aug 23, 2022
…gle quotes from os.tmpdir also sanitize dir option, the template option and the name option"

This reverts commit c8823e5.

Single quotes must not be removed from paths because they are valid (even if hard to use)
on all OSes. Double quotes are only disallowed on Windows, but tmp should not change any
arg it gets; instead, it should rely on the underlying fs API to fail with an error
that the user needs to fix.
mbargiel added a commit to mbargiel/node-tmp that referenced this issue Aug 26, 2022
silkentrance added a commit that referenced this issue Aug 26, 2022
…-name

fix #268: Revert "fix #246: remove any double quotes or single quotes…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants