mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 17:40:43 +08:00
FIX: Stop secure media URLs being censored too liberally in emails (#8817)
For example /t/ URLs were being replaced if they contained secure-media-uploads so if you made a topic called "Secure Media Uploads Are Cool" the View Topic link in the user notifications would be stripped out. Refactored code so this secure URL detection happens in one place.
This commit is contained in:
@ -288,15 +288,14 @@ module Email
|
||||
|
||||
def replace_secure_media_urls
|
||||
@fragment.css('[href]').each do |a|
|
||||
if a['href'][/#{Upload::SECURE_MEDIA_ROUTE}/]
|
||||
if Upload.secure_media_url?(a['href'])
|
||||
a.add_next_sibling "<p class='secure-media-notice'>#{I18n.t("emails.secure_media_placeholder")}</p>"
|
||||
a.remove
|
||||
end
|
||||
end
|
||||
|
||||
@fragment.search('img').each do |img|
|
||||
next unless img['src']
|
||||
if img['src'][/#{Upload::SECURE_MEDIA_ROUTE}/]
|
||||
@fragment.search('img[src]').each do |img|
|
||||
if Upload.secure_media_url?(img['src'])
|
||||
img.add_next_sibling "<p class='secure-media-notice'>#{I18n.t("emails.secure_media_placeholder")}</p>"
|
||||
img.remove
|
||||
end
|
||||
|
Reference in New Issue
Block a user