summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhttp://jneen.net/ <jneen@jneen.net>2017-02-06 10:22:31 -0800
committerhttp://jneen.net/ <jneen@jneen.net>2017-06-19 14:24:26 -0700
commitef39fb0b54d5303c53fe0751f730fe3824bbaaa0 (patch)
treee45167e197264aa156269389928a0f6b6a8952b7
parentd866c7763cdaa801a0b6dacf125250c5117843d9 (diff)
downloadgitlab-ce-ef39fb0b54d5303c53fe0751f730fe3824bbaaa0.tar.gz
unwrap all links with no href
-rw-r--r--lib/gitlab/email/html_parser.rb7
1 files changed, 7 insertions, 0 deletions
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