mirror of
https://github.com/discourse/discourse.git
synced 2025-06-07 20:54:44 +08:00
Add site setting for domains to never download images from
This commit is contained in:
@ -87,7 +87,8 @@ module Jobs
|
|||||||
def is_valid_image_url(src)
|
def is_valid_image_url(src)
|
||||||
src.present? &&
|
src.present? &&
|
||||||
!Discourse.store.has_been_uploaded?(src) &&
|
!Discourse.store.has_been_uploaded?(src) &&
|
||||||
!src.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix)
|
!src.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix) &&
|
||||||
|
SiteSetting.should_download_images?(src)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -72,6 +72,16 @@ class SiteSetting < ActiveRecord::Base
|
|||||||
.first
|
.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.should_download_images?(src)
|
||||||
|
setting = disabled_image_download_domains
|
||||||
|
return true unless setting.present?
|
||||||
|
host = URI.parse(src).host
|
||||||
|
|
||||||
|
return !(setting.split('|').include?(host))
|
||||||
|
rescue URI::InvalidURIError
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
def self.scheme
|
def self.scheme
|
||||||
use_https? ? "https" : "http"
|
use_https? ? "https" : "http"
|
||||||
end
|
end
|
||||||
|
@ -605,6 +605,7 @@ en:
|
|||||||
crawl_images: "Enable retrieving images from third party sources to insert width and height dimensions"
|
crawl_images: "Enable retrieving images from third party sources to insert width and height dimensions"
|
||||||
download_remote_images_to_local: "Download a copy of remote images hotlinked in posts"
|
download_remote_images_to_local: "Download a copy of remote images hotlinked in posts"
|
||||||
download_remote_images_threshold: "Amount of minimum available disk space required to download remote images locally (in percent)"
|
download_remote_images_threshold: "Amount of minimum available disk space required to download remote images locally (in percent)"
|
||||||
|
disabled_image_download_domains: "A pipe-delimited list of domains from which linked images will never be downloaded."
|
||||||
ninja_edit_window: "Number of seconds after posting where edits do not create a new version"
|
ninja_edit_window: "Number of seconds after posting where edits do not create a new version"
|
||||||
post_edit_time_limit: "Amount of time in minutes in which posts can be edited and deleted by the author. Set to 0 to allow editing and deleting posts at any time."
|
post_edit_time_limit: "Amount of time in minutes in which posts can be edited and deleted by the author. Set to 0 to allow editing and deleting posts at any time."
|
||||||
edit_history_visible_to_public: "Allow everyone to see previous versions of an edited post. When disabled, only staff members can view edit history."
|
edit_history_visible_to_public: "Allow everyone to see previous versions of an edited post. When disabled, only staff members can view edit history."
|
||||||
|
@ -302,6 +302,9 @@ files:
|
|||||||
test: false
|
test: false
|
||||||
default: true
|
default: true
|
||||||
download_remote_images_threshold: 20
|
download_remote_images_threshold: 20
|
||||||
|
disabled_image_download_domains:
|
||||||
|
list: true
|
||||||
|
default: ''
|
||||||
create_thumbnails: true
|
create_thumbnails: true
|
||||||
clean_up_uploads: false
|
clean_up_uploads: false
|
||||||
clean_orphan_uploads_grace_period_hours: 1
|
clean_orphan_uploads_grace_period_hours: 1
|
||||||
|
Reference in New Issue
Block a user