Recover bug of ScriptPW.Password
This commit is contained in:
parent
7a37871966
commit
a6039bcf36
5 changed files with 16 additions and 7 deletions
|
@ -3,7 +3,7 @@ setlocal
|
|||
setlocal ENABLEDELAYEDEXPANSION
|
||||
|
||||
if "%1"=="noechoback" (
|
||||
call :exprog
|
||||
call :read_s
|
||||
if ERRORLEVEL 1 exit /b 1
|
||||
) else (
|
||||
set /p INPUT=<CON >CON
|
||||
|
@ -13,7 +13,8 @@ set /p ="'%INPUT%'"<NUL
|
|||
endlocal
|
||||
exit /b 0
|
||||
|
||||
:exprog
|
||||
:: Silent Read
|
||||
:read_s
|
||||
|
||||
:: where /q powershell
|
||||
:: Win <Vista and <Server2008 don't have `where`.
|
||||
|
|
|
@ -4,7 +4,13 @@ var oExec;
|
|||
|
||||
// exit-code is not returned even if an error is thrown.
|
||||
try {
|
||||
WScript.StdOut.Write(WScript.CreateObject('ScriptPW.Password').GetPassword());
|
||||
WScript.StdOut.Write(WScript.CreateObject('ScriptPW.Password').GetPassword()
|
||||
// Bug? Illegal data may be returned when user types before initializing.
|
||||
.replace(/[\u4000-\u40FF]/g, function(chr) {
|
||||
var charCode = chr.charCodeAt(0);
|
||||
return charCode >= 0x4020 && charCode <= 0x407F ?
|
||||
String.fromCharCode(charCode - 0x4000) : '';
|
||||
}));
|
||||
} catch (e) {
|
||||
WScript.StdErr.Write(e.description);
|
||||
WScript.Quit(1);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
silent_read() {
|
||||
# Silent Read
|
||||
read_s() {
|
||||
stty --file=/dev/tty -echo echonl 2>/dev/null || \
|
||||
stty -F /dev/tty -echo echonl 2>/dev/null || \
|
||||
stty -f /dev/tty -echo echonl || exit 1
|
||||
|
@ -11,9 +12,9 @@ silent_read() {
|
|||
if [ "$1" = "noechoback" ]; then
|
||||
# Try `-s` option. *ksh have it that not `--silent`. Therefore, don't try it.
|
||||
if [ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ]; then
|
||||
IFS= read -rs INPUT </dev/tty 2>/dev/null && printf '\n' >/dev/tty || silent_read
|
||||
IFS= read -rs INPUT </dev/tty 2>/dev/null && printf '\n' >/dev/tty || read_s
|
||||
else
|
||||
silent_read
|
||||
read_s
|
||||
fi
|
||||
else
|
||||
IFS= read -r INPUT </dev/tty || exit 1
|
||||
|
|
|
@ -168,6 +168,7 @@ function _execSyncByFile(args, execOptions) {
|
|||
' & (echo 1)>%Q%' + pathDone + '%Q%'];
|
||||
} else {
|
||||
cmdArgs = ['-c',
|
||||
// Use `()`, not `{}` for `-c` (text param)
|
||||
'(' + SHELL_PATH + ' "' + SHELL_CMD + '" ' + args.join(' ') +
|
||||
'; echo $?>"' + pathStatus + '") 2>"' + pathStderr + '"' +
|
||||
' |"' + process.execPath + '" "' + __dirname + '/encrypt.js"' +
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "readline-sync",
|
||||
"version": "0.7.4",
|
||||
"version": "0.7.5",
|
||||
"title": "readlineSync",
|
||||
"description": "Synchronous Readline",
|
||||
"keywords": [
|
||||
|
|
Loading…
Reference in a new issue