Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Fix old comments

Cette révision appartient à :
sfan5 2017-05-10 13:34:25 +02:00
Parent 775f9c15ad
révision 1805f0f6aa

Voir le fichier

@ -5,7 +5,6 @@ import (
"github.com/ewhal/nyaa/util" "github.com/ewhal/nyaa/util"
"fmt" "fmt"
"html"
"html/template" "html/template"
"strconv" "strconv"
"strings" "strings"
@ -135,8 +134,7 @@ func (t *Torrent) ToJSON() TorrentJSON {
magnet := util.InfoHashToMagnet(strings.TrimSpace(t.Hash), t.Name, config.Trackers...) magnet := util.InfoHashToMagnet(strings.TrimSpace(t.Hash), t.Name, config.Trackers...)
commentsJSON := make([]CommentJSON, 0, len(t.OldComments)+len(t.Comments)) commentsJSON := make([]CommentJSON, 0, len(t.OldComments)+len(t.Comments))
for _, c := range t.OldComments { for _, c := range t.OldComments {
escapedContent := template.HTML(html.EscapeString(c.Content)) commentsJSON = append(commentsJSON, CommentJSON{Username: c.Username, Content: template.HTML(c.Content), Date: c.Date})
commentsJSON = append(commentsJSON, CommentJSON{Username: c.Username, Content: escapedContent, Date: c.Date})
} }
for _, c := range t.Comments { for _, c := range t.Comments {
commentsJSON = append(commentsJSON, CommentJSON{Username: c.User.Username, Content: util.MarkdownToHTML(c.Content), Date: c.CreatedAt}) commentsJSON = append(commentsJSON, CommentJSON{Username: c.User.Username, Content: util.MarkdownToHTML(c.Content), Date: c.CreatedAt})