From ef39fb0b54d5303c53fe0751f730fe3824bbaaa0 Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Mon, 6 Feb 2017 10:22:31 -0800 Subject: unwrap all links with no href --- lib/gitlab/email/html_parser.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/gitlab/email/html_parser.rb b/lib/gitlab/email/html_parser.rb index a4ca62bfc41..50559a48973 100644 --- a/lib/gitlab/email/html_parser.rb +++ b/lib/gitlab/email/html_parser.rb @@ -17,6 +17,13 @@ module Gitlab def filter_replies! document.xpath('//blockquote').each(&:remove) document.xpath('//table').each(&:remove) + + # bogus links with no href are sometimes added by outlook, + # and can result in Html2Text adding extra square brackets + # to the text, so we unwrap them here. + document.xpath('//a[not(@href)]').each do |link| + link.replace(link.children) + end end def filtered_html -- cgit v1.2.1