From e7e2edf76c7b15f0031136e71da0a8f4f06cc19f Mon Sep 17 00:00:00 2001 From: 1138-4EB <1138-4EB@users.noreply.github.com> Date: Mon, 23 Apr 2018 21:21:18 +0200 Subject: [PATCH] fix #311, fix #312 (see filebrowser/frontend#7) (#405) Former-commit-id: 2a2fe8e441a30073ff9dbb4ba4f6c6235709f158 [formerly 75aa9ca68f6fe2e20ff01d027c9c18e49fe75739] [formerly 371c60a517b81399929f520abc25462f7a271083 [formerly c6eb4fbac563c4f09813ebb665a4f3e549df3a3b]] Former-commit-id: e501e318c908fd83ffe7a4984ea732385116aa97 [formerly c5a2a983c3960e2af98915b89a6abb3f2ae3bbde] Former-commit-id: 90dd43012239882bf72855df4f538fa59f699d64 --- http/websockets.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/http/websockets.go b/http/websockets.go index 6e191f01..64bf92cc 100644 --- a/http/websockets.go +++ b/http/websockets.go @@ -57,13 +57,14 @@ func command(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) allowed := false for _, cmd := range c.User.Commands { - if cmd == command[0] { + if regexp.MustCompile(cmd).MatchString(command[0]) { allowed = true + break } } if !allowed { - err = conn.WriteMessage(websocket.BinaryMessage, cmdNotAllowed) + err = conn.WriteMessage(websocket.TextMessage, cmdNotAllowed) if err != nil { return http.StatusInternalServerError, err } @@ -71,9 +72,9 @@ func command(c *fm.Context, w http.ResponseWriter, r *http.Request) (int, error) return 0, nil } - // Check if the program is talled is installed on the computer. + // Check if the program is installed on the computer. if _, err = exec.LookPath(command[0]); err != nil { - err = conn.WriteMessage(websocket.BinaryMessage, cmdNotImplemented) + err = conn.WriteMessage(websocket.TextMessage, cmdNotImplemented) if err != nil { return http.StatusInternalServerError, err }