feat: comment text to HTML with sanitization

This commit is contained in:
httpjamesm 2022-12-29 13:09:25 -05:00
parent 3b79efc83c
commit 11efaf854d
2 changed files with 5 additions and 2 deletions

View File

@ -1,7 +1,9 @@
package types
import "html/template"
type FilteredComment struct {
Text string
Text template.HTML
Timestamp string
AuthorName string
AuthorURL string

View File

@ -2,6 +2,7 @@ package utils
import (
"anonymousoverflow/src/types"
"html/template"
"github.com/PuerkitoBio/goquery"
)
@ -40,7 +41,7 @@ func FindAndReturnComments(inHtml string, postLayout *goquery.Selection) (commen
commentTimestamp := commentBody.Find("span.relativetime-clean").Text()
newFilteredComment := types.FilteredComment{
Text: commentCopy,
Text: template.HTML(commentCopy),
Timestamp: commentTimestamp,
AuthorName: commentAuthor.Text(),
AuthorURL: commentAuthorURL,