mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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?
|
return @raw_links if @raw_links.present?
|
||||||
|
|
||||||
@raw_links = []
|
@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
|
# 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
|
@raw_links << l['href'].to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -176,6 +176,11 @@ describe PostAnalyzer do
|
|||||||
expect(post_analyzer.link_count).to eq(0)
|
expect(post_analyzer.link_count).to eq(0)
|
||||||
end
|
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
|
it "finds links from markdown" do
|
||||||
Oneboxer.stubs :onebox
|
Oneboxer.stubs :onebox
|
||||||
post_analyzer = PostAnalyzer.new(raw_post_one_link_md, default_topic_id)
|
post_analyzer = PostAnalyzer.new(raw_post_one_link_md, default_topic_id)
|
||||||
|
@ -410,7 +410,6 @@ describe Post do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "finds links from HTML" do
|
it "finds links from HTML" do
|
||||||
|
|
||||||
expect(post_two_links.link_count).to eq(2)
|
expect(post_two_links.link_count).to eq(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user