mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-03-14 00:50:14 -04:00
Fix relative URLs in plain text emails
This commit is contained in:
parent
7aad487d4c
commit
db5f2ae88c
1 changed files with 7 additions and 0 deletions
|
@ -49,6 +49,13 @@ module Email
|
|||
|
||||
@message.parts[0].body = @message.parts[0].body.to_s.gsub(/\[\/?email-indent\]/, '')
|
||||
|
||||
# Fix relative (ie upload) HTML links in markdown which do not work well in plain text emails.
|
||||
# These are the links we add when a user uploads a file or image.
|
||||
# Ideally we would parse general markdown into plain text, but that is almost an intractable problem.
|
||||
url_prefix = Discourse.base_url
|
||||
@message.parts[0].body = @message.parts[0].body.to_s.gsub(/<a class="attachment" href="(\/uploads\/default\/[^"]+)">([^<]*)<\/a>/, '[\2]('+url_prefix+'\1)')
|
||||
@message.parts[0].body = @message.parts[0].body.to_s.gsub(/<img src="(\/uploads\/default\/[^"]+)"([^>]*)>/, '')
|
||||
|
||||
@message.text_part.content_type = 'text/plain; charset=UTF-8'
|
||||
|
||||
# Set up the email log
|
||||
|
|
Loading…
Reference in a new issue