From 948617cb0b2e67b3186e0525c652402aa60298fa Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 18 Mar 2015 16:25:24 +1100 Subject: [PATCH] FIX: ruby 2.2 using new parsing library which is way too lax --- app/models/post_analyzer.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/post_analyzer.rb b/app/models/post_analyzer.rb index dabb36733eb..b60502b98fc 100644 --- a/app/models/post_analyzer.rb +++ b/app/models/post_analyzer.rb @@ -55,6 +55,12 @@ class PostAnalyzer @raw_mentions = results.uniq.map { |un| un.first.downcase.gsub!(/^@/, '') } 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 def linked_hosts return {} if raw_links.blank? @@ -64,7 +70,7 @@ class PostAnalyzer raw_links.each do |u| begin - uri = URI.parse(u) + uri = self.class.parse_uri_rfc2396(u) host = uri.host @linked_hosts[host] ||= 1 unless host.nil? rescue URI::InvalidURIError