feat: comment text to HTML with sanitization
This commit is contained in:
parent
3b79efc83c
commit
11efaf854d
@ -1,7 +1,9 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
|
import "html/template"
|
||||||
|
|
||||||
type FilteredComment struct {
|
type FilteredComment struct {
|
||||||
Text string
|
Text template.HTML
|
||||||
Timestamp string
|
Timestamp string
|
||||||
AuthorName string
|
AuthorName string
|
||||||
AuthorURL string
|
AuthorURL string
|
||||||
|
@ -2,6 +2,7 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"anonymousoverflow/src/types"
|
"anonymousoverflow/src/types"
|
||||||
|
"html/template"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
)
|
)
|
||||||
@ -40,7 +41,7 @@ func FindAndReturnComments(inHtml string, postLayout *goquery.Selection) (commen
|
|||||||
commentTimestamp := commentBody.Find("span.relativetime-clean").Text()
|
commentTimestamp := commentBody.Find("span.relativetime-clean").Text()
|
||||||
|
|
||||||
newFilteredComment := types.FilteredComment{
|
newFilteredComment := types.FilteredComment{
|
||||||
Text: commentCopy,
|
Text: template.HTML(commentCopy),
|
||||||
Timestamp: commentTimestamp,
|
Timestamp: commentTimestamp,
|
||||||
AuthorName: commentAuthor.Text(),
|
AuthorName: commentAuthor.Text(),
|
||||||
AuthorURL: commentAuthorURL,
|
AuthorURL: commentAuthorURL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user