From a8b51124ba822703cb7bd70cea9ec46e4d0ee287 Mon Sep 17 00:00:00 2001 From: ThibG Date: Wed, 3 Jan 2018 20:51:33 +0100 Subject: Don't normalize URLs in toots (#6134) * Don't normalize URLs in toots URL normalization is ill-defined and may cause certain links to break. * Change specs since we are not normalizing user-provided URLs --- app/lib/formatter.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/lib') diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index f5bf64cc7..8c0f8cebc 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -171,10 +171,10 @@ class Formatter end def link_to_url(entity) - normalized_url = Addressable::URI.parse(entity[:url]).normalize - html_attrs = { target: '_blank', rel: 'nofollow noopener' } + url = Addressable::URI.parse(entity[:url]) + html_attrs = { target: '_blank', rel: 'nofollow noopener' } - Twitter::Autolink.send(:link_to_text, entity, link_html(entity[:url]), normalized_url, html_attrs) + Twitter::Autolink.send(:link_to_text, entity, link_html(entity[:url]), url, html_attrs) rescue Addressable::URI::InvalidURIError, IDN::Idna::IdnaError encode(entity[:url]) end -- cgit