sanitize PostTitle

This commit is contained in:
Umputun
2021-09-01 13:56:06 -05:00
parent 8754add874
commit a7b44eee1a
2 changed files with 5 additions and 0 deletions
+1
View File
@@ -128,6 +128,7 @@ func (c *Comment) Sanitize() {
c.User.Name = c.escapeHTMLWithSome(c.User.Name)
c.User.Picture = c.SanitizeAsURL(c.User.Picture)
c.Locator.URL = c.SanitizeAsURL(c.Locator.URL)
c.PostTitle = p.Sanitize(c.PostTitle)
}
// Snippet from comment's text
+4
View File
@@ -73,6 +73,10 @@ func TestComment_Sanitize(t *testing.T) {
out: Comment{Text: "<img src=x onerror=alert(1)>",
Locator: Locator{URL: "/p/2021/03/23/prep-747/#remark42__comment-1b365913-7056-4920-b9ad-01304bdda085"}},
},
{
inp: Comment{Text: "blah blah", PostTitle: "<script>alert()</script>something"},
out: Comment{Text: "blah blah", PostTitle: "something"},
},
}
for n, tt := range tbl {