瀏覽代碼

jsre: leave out lines from history containing methods of the personal module

zelig 10 年之前
父節點
當前提交
6628eeb6ca
共有 1 個文件被更改,包括 17 次插入2 次删除
  1. 17 2
      cmd/geth/js.go

+ 17 - 2
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 {