fix: remove extra spaces after the first command (fixes #178)

This commit is contained in:
evilsocket 2018-03-18 11:10:44 +01:00
commit 641ae0cd00
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -8,6 +8,7 @@ import (
"net"
"os"
"os/signal"
"regexp"
"runtime"
"runtime/pprof"
"sort"
@ -32,6 +33,8 @@ var (
ErrAlreadyStarted = errors.New("Module is already running.")
ErrAlreadyStopped = errors.New("Module is not running.")
reCmdSpaceCleaner = regexp.MustCompile(`^([^\s]+)\s+(.+)$`)
)
type Session struct {
@ -479,6 +482,11 @@ func (s *Session) RunCaplet(filename string) error {
func (s *Session) Run(line string) error {
line = core.TrimRight(line)
// remove extra spaces after the first command
// so that 'arp.spoof on' is normalized
// to 'arp.spoof on' (fixes #178)
line = reCmdSpaceCleaner.ReplaceAllString(line, "$1 $2")
for _, h := range s.CoreHandlers {
if parsed, args := h.Parse(line); parsed == true {
return h.Exec(args, s)