mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:19:27 +08:00
FIX: Don't allow links with no href
This commit is contained in:
parent
9e7d5a3cdf
commit
31d0998506
|
@ -111,9 +111,9 @@ class PostAnalyzer
|
|||
return @raw_links if @raw_links.present?
|
||||
|
||||
@raw_links = []
|
||||
cooked_stripped.css("a[href]").each do |l|
|
||||
cooked_stripped.css("a").each do |l|
|
||||
# Don't include @mentions in the link count
|
||||
next if l['href'].blank? || link_is_a_mention?(l)
|
||||
next if link_is_a_mention?(l)
|
||||
@raw_links << l['href'].to_s
|
||||
end
|
||||
|
||||
|
|
|
@ -176,6 +176,11 @@ describe PostAnalyzer do
|
|||
expect(post_analyzer.link_count).to eq(0)
|
||||
end
|
||||
|
||||
it "returns links with href=''" do
|
||||
post_analyzer = PostAnalyzer.new('<a href="">Hello world</a>', nil)
|
||||
expect(post_analyzer.link_count).to eq(1)
|
||||
end
|
||||
|
||||
it "finds links from markdown" do
|
||||
Oneboxer.stubs :onebox
|
||||
post_analyzer = PostAnalyzer.new(raw_post_one_link_md, default_topic_id)
|
||||
|
|
|
@ -410,7 +410,6 @@ describe Post do
|
|||
end
|
||||
|
||||
it "finds links from HTML" do
|
||||
|
||||
expect(post_two_links.link_count).to eq(2)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user