mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: should look through posts for image markdown
Downloaded onebox images only included in the cooked HTML content. So we have to check 'post.cooked' instead of 'raw'. bfdd0fe64cc90707569a158b0dbdecedf3d03986
This commit is contained in:
@ -391,9 +391,8 @@ end
|
||||
desc 'Finds missing post upload records from cooked HTML content'
|
||||
task 'posts:missing_uploads' => :environment do
|
||||
name = "missing_uploads"
|
||||
db_name = RailsMultisite::ConnectionManagement.current_db
|
||||
PostCustomField.where(name: name).destroy_all
|
||||
posts = Post.where("(posts.cooked LIKE '%<a %' OR posts.cooked LIKE '%<img %') AND posts.cooked LIKE '%/uploads/#{db_name}/%'").select(:id, :cooked)
|
||||
posts = Post.have_uploads.select(:id, :cooked)
|
||||
count = 0
|
||||
|
||||
posts.find_each do |post|
|
||||
@ -401,7 +400,7 @@ task 'posts:missing_uploads' => :environment do
|
||||
|
||||
Nokogiri::HTML::fragment(post.cooked).css("a/@href", "img/@src").each do |media|
|
||||
src = media.value
|
||||
next if src.blank? || (src =~ /\/uploads\/#{db_name}\//).blank?
|
||||
next if src.blank? || (src =~ /\/uploads\/#{RailsMultisite::ConnectionManagement.current_db}\//).blank?
|
||||
|
||||
src = "#{SiteSetting.force_https ? "https" : "http"}:#{src}" if src.start_with?("//")
|
||||
next unless Discourse.store.has_been_uploaded?(src) || src =~ /\A\/[^\/]/i
|
||||
|
Reference in New Issue
Block a user