mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 23:52:27 +08:00
FIX: Resolve pull hotlinked image and broken link issues for secure media URLs (#8777)
When pull_hotlinked_images tried to run on posts with secure media (which had already been downloaded from external sources) we were getting a 404 when trying to download the image because the secure endpoint doesn't allow anon downloads. Also, we were getting into an infinite loop of pull_hotlinked_images because the job didn't consider the secure media URLs as "downloaded" already so it kept trying to download them over and over. In this PR I have also refactored secure-media-upload URL checks and mutations into single source of truth in Upload, adding a SECURE_MEDIA_ROUTE constant to check URLs against too.
This commit is contained in:
@ -72,7 +72,7 @@ module PrettyText
|
||||
|
||||
short_urls.each do |short_url|
|
||||
result[short_url] = {
|
||||
url: secure_media ? secure_media_url(url) : Discourse.store.cdn_url(url),
|
||||
url: secure_media ? Upload.secure_media_url_from_upload_url(url) : Discourse.store.cdn_url(url),
|
||||
short_path: Upload.short_path(sha1: sha1, extension: extension),
|
||||
base62_sha1: Upload.base62_sha1(sha1)
|
||||
}
|
||||
@ -84,10 +84,6 @@ module PrettyText
|
||||
result
|
||||
end
|
||||
|
||||
def secure_media_url(url)
|
||||
url.sub(SiteSetting.Upload.absolute_base_url, "/secure-media-uploads")
|
||||
end
|
||||
|
||||
def get_topic_info(topic_id)
|
||||
return unless topic_id.is_a?(Integer)
|
||||
# TODO this only handles public topics, secured one do not get this
|
||||
|
Reference in New Issue
Block a user