FIX: Don't count HTML comments when calculating reply length. (#11658)

We'll remove them when we sanitize the post raw content.
This commit is contained in:
Roman Rizzi
2021-01-07 15:44:17 -03:00
committed by GitHub
parent 2e3b3ec2de
commit e696cba071
4 changed files with 41 additions and 2 deletions

View File

@@ -57,6 +57,24 @@ describe PostValidator do
validator.stripped_length(post)
expect(post.errors.count).to eq(0)
end
it "ignores an html comment" do
post.raw = "<!-- an html comment -->abc"
validator.stripped_length(post)
expect(post.errors.count).to eq(1)
end
it "ignores multiple html comments" do
post.raw = "<!-- an html comment -->\n abc \n<!-- a comment -->"
validator.stripped_length(post)
expect(post.errors.count).to eq(1)
end
it "ignores nested html comments" do
post.raw = "<!-- <!-- an html comment --> -->"
validator.stripped_length(post)
expect(post.errors.count).to eq(1)
end
end
context "too_many_posts" do