mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
fix: remove extra spaces after the first command (fixes #178)
This commit is contained in:
parent
b151e98289
commit
641ae0cd00
1 changed files with 8 additions and 0 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -32,6 +33,8 @@ var (
|
||||||
|
|
||||||
ErrAlreadyStarted = errors.New("Module is already running.")
|
ErrAlreadyStarted = errors.New("Module is already running.")
|
||||||
ErrAlreadyStopped = errors.New("Module is not running.")
|
ErrAlreadyStopped = errors.New("Module is not running.")
|
||||||
|
|
||||||
|
reCmdSpaceCleaner = regexp.MustCompile(`^([^\s]+)\s+(.+)$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
type Session struct {
|
type Session struct {
|
||||||
|
@ -479,6 +482,11 @@ func (s *Session) RunCaplet(filename string) error {
|
||||||
|
|
||||||
func (s *Session) Run(line string) error {
|
func (s *Session) Run(line string) error {
|
||||||
line = core.TrimRight(line)
|
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 {
|
for _, h := range s.CoreHandlers {
|
||||||
if parsed, args := h.Parse(line); parsed == true {
|
if parsed, args := h.Parse(line); parsed == true {
|
||||||
return h.Exec(args, s)
|
return h.Exec(args, s)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue