mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 04:11:12 +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:
@ -284,9 +284,8 @@ class CookedPostProcessor
|
||||
|
||||
# we can't direct FastImage to our secure-media-uploads url because it bounces
|
||||
# anonymous requests with a 404 error
|
||||
if url&.include?("/secure-media-uploads/")
|
||||
secure_upload_s3_path = absolute_url.sub(Discourse.base_url, "").sub("/secure-media-uploads/", "")
|
||||
absolute_url = Discourse.store.signed_url_for_path(secure_upload_s3_path)
|
||||
if url && Upload.secure_media_url?(url)
|
||||
absolute_url = Upload.signed_url_from_secure_media_url(absolute_url)
|
||||
end
|
||||
|
||||
return unless is_valid_image_url?(absolute_url)
|
||||
|
Reference in New Issue
Block a user