backend: fix XSS in team name and events

This commit is contained in:
nemunaire 2020-01-30 18:59:45 +01:00
parent ca8bac1ac8
commit 429cd3010c
4 changed files with 9 additions and 5 deletions

View file

@ -5,6 +5,7 @@ import (
"encoding/binary"
"encoding/json"
"fmt"
"html"
"io/ioutil"
"log"
"math/rand"
@ -49,7 +50,7 @@ func treatOpeningHint(pathname string, team fic.Team) {
log.Printf("%s [WRN] %s\n", id, err)
} else if theme, err := fic.GetTheme(exercice.IdTheme); err != nil {
log.Printf("%s [WRN] %s\n", id, err)
} else if _, err = fic.NewEvent(fmt.Sprintf("L'équipe %s a dévoilé un indice pour le <strong>%d<sup>e</sup></strong> défi %s&#160;!", team.Name, lvl, theme.Name), "info"); err != nil {
} else if _, err = fic.NewEvent(fmt.Sprintf("L'équipe %s a dévoilé un indice pour le <strong>%d<sup>e</sup></strong> défi %s&#160;!", html.EscapeString(team.Name), lvl, theme.Name), "info"); err != nil {
log.Printf("%s [WRN] Unable to create event: %s\n", id, err)
}