Skip to content

Commit

Permalink
player/player.go: ExecuteCommand: use strings.CutPrefix to make sure …
Browse files Browse the repository at this point in the history
…the command starts with "/". (#988)

* player/player.go: add empty string check in command resolution.

* fix: player/player.go: use strings.CutPrefix.
  • Loading branch information
Dasciam authored Jan 8, 2025
1 parent 16b0d3e commit d02eed9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,16 @@ func (p *Player) ExecuteCommand(commandLine string) {
return
}
args := strings.Split(commandLine, " ")
command, ok := cmd.ByAlias(args[0][1:])

name, ok := strings.CutPrefix(args[0], "/")
if !ok {
return
}

command, ok := cmd.ByAlias(name)
if !ok {
o := &cmd.Output{}
o.Errort(cmd.MessageUnknown, args[0])
o.Errort(cmd.MessageUnknown, name)
p.SendCommandOutput(o)
return
}
Expand Down

0 comments on commit d02eed9

Please sign in to comment.