mirror of
https://github.com/discourse/discourse.git
synced 2024-12-16 23:53:43 +08:00
SECURITY: Stripping links could unescape html fragments
This commit is contained in:
parent
e4287d9de9
commit
570e3b3e79
|
@ -250,7 +250,7 @@ module PrettyText
|
|||
|
||||
# If the user is not basic, strip links from their bio
|
||||
fragment = Nokogiri::HTML.fragment(string)
|
||||
fragment.css('a').each {|a| a.replace(a.text) }
|
||||
fragment.css('a').each {|a| a.replace(a.inner_html) }
|
||||
fragment.to_html
|
||||
end
|
||||
|
||||
|
|
|
@ -210,6 +210,10 @@ describe PrettyText do
|
|||
it "strips links but leaves the text content" do
|
||||
expect(PrettyText.strip_links("I'm the linked <a href='http://en.wikipedia.org/wiki/Batman'>batman</a>")).to eq("I'm the linked batman")
|
||||
end
|
||||
|
||||
it "escapes the text content" do
|
||||
expect(PrettyText.strip_links("I'm the linked <a href='http://en.wikipedia.org/wiki/Batman'><batman></a>")).to eq("I'm the linked <batman>")
|
||||
end
|
||||
end
|
||||
|
||||
describe "make_all_links_absolute" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user