Skip to content

Commit

Permalink
Escape html commands string
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Aug 6, 2021
1 parent 724de59 commit 402a848
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"html"
"io"
"os"
"runtime"
Expand Down Expand Up @@ -40,22 +41,22 @@ var h = hub{
}

const commands = `{
"Commands": [
"list",
"open < portName > < baud > [bufferAlgorithm: ({default}, timed, timedraw, timedbinary)]",
"send < portName > < cmd >",
"sendnobuf < portName > < cmd >",
"close < portName >",
"restart",
"exit",
"killupload",
"downloadtool < tool > < toolVersion: {latest} > < pack: {arduino} > < behaviour: {keep} >",
"log",
"memorystats",
"gc",
"hostname",
"version"
]
"Commands": [
"list",
"open <portName> <baud> [bufferAlgorithm: ({default}, timed, timedraw, timedbinary)]",
"send <portName> <cmd>",
"sendnobuf <portName> <cmd>",
"close <portName>",
"restart",
"exit",
"killupload",
"downloadtool <tool> <toolVersion: {latest}> <pack: {arduino}> <behaviour: {keep}>",
"log",
"memorystats",
"gc",
"hostname",
"version"
]
}`

func (h *hub) unregisterConnection(c *connection) {
Expand Down Expand Up @@ -86,7 +87,7 @@ func (h *hub) run() {
h.connections[c] = true
// send supported commands
c.send <- []byte(fmt.Sprintf(`{"Version" : "%s"} `, version))
c.send <- []byte(commands)
c.send <- []byte(html.EscapeString(commands))
c.send <- []byte(fmt.Sprintf(`{"Hostname" : "%s"} `, *hostname))
c.send <- []byte(fmt.Sprintf(`{"OS" : "%s"} `, runtime.GOOS))
case c := <-h.unregister:
Expand Down

0 comments on commit 402a848

Please sign in to comment.