Uh oh!
There was an error while loading. Please reload this page.
repl: make sure historyPath is trimmed - #4539
Conversation
There was a problem hiding this comment.
If we are anyway going to use the actual value as it is, then why not just
if(opts.terminal&&typeofenv.NODE_REPL_HISTORY==='string'&&env.NODE_REPL_HISTORY.trim()!==''){
...
}There was a problem hiding this comment.
Because then we would have to trim the string more than once before it is passed to setupHistory
There was a problem hiding this comment.
@evanlucas How so? We are anyway passing env.NODE_REPL_HISTORY as it is to setupHistory.
There was a problem hiding this comment.
Oh wow. Not what I meant to do. Will fix shortly. I was meaning to pass the trimmed historyPath to setupHistory
thefourtheye
commented
Jan 5, 2016
Hmmm, I still feel that the type checking would be better here. Because, users can tamper |
evanlucas
commented
Jan 5, 2016
process.env gets coerced to a string when set though. |
thefourtheye
commented
Jan 5, 2016
TIL :-) Thanks :P In that case, we can simply do consthistoryPath=env.NODE_REPL_HISTORY.trim();if(historyPath){returnsetupHistory(...);}Right? |
evanlucas
commented
Jan 5, 2016
We can't do that because the key may not exist at all: |
thefourtheye
commented
Jan 5, 2016
Ah, right. Thanks :) Change LGTM. Let's see what @Fishrock123 thinks. Apart from this, should we warn the user that the file name is an empty string? |
There was a problem hiding this comment.
All of this logic, including the check for empty string might make more sense inside of setupHistory().
cjihrig
commented
Jan 5, 2016
This probably warrants a tiny documentation update to mention that whitespace is stripped. Right now it only says:
After this change, that would only be partially correct. |
jasnell
commented
Jan 5, 2016
LGTM. What do y'all think about landing this in v4? |
evanlucas
commented
Jan 6, 2016
@cjihrig nits addressed. PTAL. @jasnell I think it should definitely be backported to LTS. Especially considering the problems it could cause on windows as stated in #4522 (comment) |
There was a problem hiding this comment.
This condition is not necessary. If the control reaches this point, then historyPath is not an empty string.
There was a problem hiding this comment.
It could be undefined though
cjihrig
commented
Jan 6, 2016
One comment, then LGTM. |
evanlucas
commented
Jan 7, 2016
Ok, updated. PTAL @cjihrig |
cjihrig
commented
Jan 7, 2016
Fishrock123
commented
Jan 7, 2016
Looking, sorry for the delay. |
There was a problem hiding this comment.
Wait what else would it be? We don't export setupHistory().
There was a problem hiding this comment.
if process.env.NODE_REPL_HISTORY is undefined, then it will be undefined
jasnell
commented
Jan 7, 2016
LGTM once @Fishrock123 is happy :-) |
Fishrock123
commented
Jan 8, 2016
Seems fine to me. |
evanlucas
commented
Jan 14, 2016
Rebased after the eslint changes. @Fishrock123@jasnell@cjihrig@thefourtheye LGTY? |
cjihrig
commented
Jan 14, 2016
Yep, still LGTM. |
Fishrock123
commented
Jan 16, 2016
LGTM |
If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: nodejs#4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>evanlucas
commented
Jan 16, 2016
Landed in da550aa. Thanks! |
If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: #4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: #4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: #4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: nodejs#4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: nodejs#4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
PR-URL: nodejs#4539
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
If one were to set NODE_REPL_HISTORY to a string that contains only a
space (" "), then the history file would be created with that name
which can cause problems are certain systems.
Related: #4522
R= @Fishrock123?