mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: ruby 2.2 using new parsing library which is way too lax
This commit is contained in:
parent
a0369855b9
commit
948617cb0b
@ -55,6 +55,12 @@ class PostAnalyzer
|
|||||||
@raw_mentions = results.uniq.map { |un| un.first.downcase.gsub!(/^@/, '') }
|
@raw_mentions = results.uniq.map { |un| un.first.downcase.gsub!(/^@/, '') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# from rack ... compat with ruby 2.2
|
||||||
|
def self.parse_uri_rfc2396(uri)
|
||||||
|
@parser ||= defined?(URI::RFC2396_Parser) ? URI::RFC2396_Parser.new : URI
|
||||||
|
@parser.parse(uri)
|
||||||
|
end
|
||||||
|
|
||||||
# Count how many hosts are linked in the post
|
# Count how many hosts are linked in the post
|
||||||
def linked_hosts
|
def linked_hosts
|
||||||
return {} if raw_links.blank?
|
return {} if raw_links.blank?
|
||||||
@ -64,7 +70,7 @@ class PostAnalyzer
|
|||||||
|
|
||||||
raw_links.each do |u|
|
raw_links.each do |u|
|
||||||
begin
|
begin
|
||||||
uri = URI.parse(u)
|
uri = self.class.parse_uri_rfc2396(u)
|
||||||
host = uri.host
|
host = uri.host
|
||||||
@linked_hosts[host] ||= 1 unless host.nil?
|
@linked_hosts[host] ||= 1 unless host.nil?
|
||||||
rescue URI::InvalidURIError
|
rescue URI::InvalidURIError
|
||||||
|
Loading…
Reference in New Issue
Block a user