aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-08-04 18:10:59 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-08-04 18:10:59 +0800
commitff66e8fa2935d59d5104e324861d9e1bb517ffaa (patch)
treeebfff96ebd58445b582a97911fcf355bbc53e58f /cmd
parent17b481e3c30c10866fe756833e145717ec29d918 (diff)
parent6628eeb6ca79eeee233fe1c352c771d092541224 (diff)
downloadgo-tangerine-ff66e8fa2935d59d5104e324861d9e1bb517ffaa.tar
go-tangerine-ff66e8fa2935d59d5104e324861d9e1bb517ffaa.tar.gz
go-tangerine-ff66e8fa2935d59d5104e324861d9e1bb517ffaa.tar.bz2
go-tangerine-ff66e8fa2935d59d5104e324861d9e1bb517ffaa.tar.lz
go-tangerine-ff66e8fa2935d59d5104e324861d9e1bb517ffaa.tar.xz
go-tangerine-ff66e8fa2935d59d5104e324861d9e1bb517ffaa.tar.zst
go-tangerine-ff66e8fa2935d59d5104e324861d9e1bb517ffaa.zip
Merge pull request #1562 from ethersphere/blankpasswd
jsre: leave out lines from history possibly containing passwords
Diffstat (limited to 'cmd')
-rw-r--r--cmd/geth/js.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/cmd/geth/js.go b/cmd/geth/js.go
index b856e837b..bf56423ec 100644
--- a/cmd/geth/js.go
+++ b/cmd/geth/js.go
@@ -23,6 +23,7 @@ import (
"os"
"os/signal"
"path/filepath"
+ "regexp"
"strings"
"sort"
@@ -44,6 +45,10 @@ import (
"github.com/robertkrimen/otto"
)
+var passwordRegexp = regexp.MustCompile("personal.[nu]")
+
+const passwordRepl = ""
+
type prompter interface {
AppendHistory(string)
Prompt(p string) (string, error)
@@ -413,8 +418,10 @@ func (self *jsre) interactive() {
str += input + "\n"
self.setIndent()
if indentCount <= 0 {
- hist := str[:len(str)-1]
- self.AppendHistory(hist)
+ hist := hidepassword(str[:len(str)-1])
+ if len(hist) > 0 {
+ self.AppendHistory(hist)
+ }
self.parseInput(str)
str = ""
}
@@ -422,6 +429,14 @@ func (self *jsre) interactive() {
}
}
+func hidepassword(input string) string {
+ if passwordRegexp.MatchString(input) {
+ return passwordRepl
+ } else {
+ return input
+ }
+}
+
func (self *jsre) withHistory(op func(*os.File)) {
datadir := common.DefaultDataDir()
if self.ethereum != nil {