mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 23:58:26 +08:00
FIX: attachment links in mail lacks protocol
This commit is contained in:
@ -27,6 +27,7 @@ module Email
|
||||
def format_basic
|
||||
uri = URI(Discourse.base_url)
|
||||
|
||||
# images
|
||||
@fragment.css('img').each do |img|
|
||||
|
||||
next if img['class'] == 'site-logo'
|
||||
@ -51,6 +52,20 @@ module Email
|
||||
img['src'] = "#{uri.scheme}:#{img['src']}"
|
||||
end
|
||||
end
|
||||
|
||||
# attachments
|
||||
@fragment.css('a.attachment').each do |a|
|
||||
|
||||
# ensure all urls are absolute
|
||||
if a['href'] =~ /^\/[^\/]/
|
||||
a['href'] = "#{Discourse.base_url}#{a['href']}"
|
||||
end
|
||||
|
||||
# ensure no schemaless urls
|
||||
if a['href'] && a['href'].starts_with?("//")
|
||||
a['href'] = "#{uri.scheme}:#{a['href']}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def format_notification
|
||||
|
Reference in New Issue
Block a user