mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 07:14:41 +08:00
Fix HTML tags in topic titles.
We no longer sanitize titles before saving to the database since it would cause problems like HTML entities showing up when you try to edit a topic title. It isn't even really necessary since we only render fancy_title directly and never title. The escaping logic used here is the same that is used both in lodash and onebox. See: 1. https://github.com/discourse/onebox/pull/190/files 2. https://github.com/lodash/lodash/blob/2.4.1/dist/lodash.compat.js#L6194
This commit is contained in:
@ -121,15 +121,15 @@ describe Topic do
|
||||
let(:topic_script) { build_topic_with_title("Topic with <script>alert('title')</script> script in its title" ) }
|
||||
|
||||
it "escapes script contents" do
|
||||
topic_script.title.should == "Topic with script in its title"
|
||||
topic_script.fancy_title.should == "Topic with <script>alert(‘title’)</script> script in its title"
|
||||
end
|
||||
|
||||
it "escapes bold contents" do
|
||||
topic_bold.title.should == "Topic with bold text in its title"
|
||||
topic_bold.fancy_title.should == "Topic with <b>bold</b> text in its title"
|
||||
end
|
||||
|
||||
it "escapes image contents" do
|
||||
topic_image.title.should == "Topic with image in its title"
|
||||
topic_image.fancy_title.should == "Topic with <img src=‘something’> image in its title"
|
||||
end
|
||||
|
||||
end
|
||||
@ -142,8 +142,8 @@ describe Topic do
|
||||
SiteSetting.stubs(:title_fancy_entities).returns(false)
|
||||
end
|
||||
|
||||
it "doesn't change the title to add entities" do
|
||||
topic.fancy_title.should == topic.title
|
||||
it "doesn't add entities to the title" do
|
||||
topic.fancy_title.should == ""this topic" -- has ``fancy stuff''"
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user