Skip to content

Commit 66d74df

Browse files
fjlobscuren
authored andcommitted
[release 1.4.5] cmd/geth: fix console history exclusion
Calls to 'personal' API should be excluded from console history because they can be called with an account passphrase as argument. The check for such calls was inverted and didn't work. (cherry picked from commit 86da6fe) Conflicts: cmd/geth/js.go
1 parent b950a29 commit 66d74df

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

cmd/geth/js.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import (
4141
)
4242

4343
var (
44-
leadingSpace = regexp.MustCompile("^ ")
4544
passwordRegexp = regexp.MustCompile("personal.[nus]")
4645
onlyws = regexp.MustCompile("^\\s*$")
4746
exit = regexp.MustCompile("^\\s*exit\\s*;*\\s*$")
@@ -361,7 +360,7 @@ func (self *jsre) interactive() {
361360
str += input + "\n"
362361
self.setIndent()
363362
if indentCount <= 0 {
364-
if mustLogInHistory(str) {
363+
if !excludeFromHistory(str) {
365364
utils.Stdin.AppendHistory(str[:len(str)-1])
366365
}
367366
self.parseInput(str)
@@ -371,10 +370,8 @@ func (self *jsre) interactive() {
371370
}
372371
}
373372

374-
func mustLogInHistory(input string) bool {
375-
return len(input) == 0 ||
376-
passwordRegexp.MatchString(input) ||
377-
!leadingSpace.MatchString(input)
373+
func excludeFromHistory(input string) bool {
374+
return len(input) == 0 || input[0] == ' ' || passwordRegexp.MatchString(input)
378375
}
379376

380377
func (self *jsre) withHistory(datadir string, op func(*os.File)) {

0 commit comments

Comments
 (0)