mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: onebox links should respect nofollow settings
This commit is contained in:
parent
1b510447db
commit
f38abbe279
@ -2,6 +2,7 @@
|
|||||||
# For example, inserting the onebox content, or image sizes/thumbnails.
|
# For example, inserting the onebox content, or image sizes/thumbnails.
|
||||||
|
|
||||||
require_dependency 'url_helper'
|
require_dependency 'url_helper'
|
||||||
|
require_dependency 'pretty_text'
|
||||||
|
|
||||||
class CookedPostProcessor
|
class CookedPostProcessor
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
@ -13,9 +14,10 @@ class CookedPostProcessor
|
|||||||
@previous_cooked = (@post.cooked || "").dup
|
@previous_cooked = (@post.cooked || "").dup
|
||||||
# NOTE: we re-cook the post here in order to prevent timing issues with edits
|
# NOTE: we re-cook the post here in order to prevent timing issues with edits
|
||||||
# cf. https://meta.discourse.org/t/edit-of-rebaked-post-doesnt-show-in-html-only-in-raw/33815/6
|
# cf. https://meta.discourse.org/t/edit-of-rebaked-post-doesnt-show-in-html-only-in-raw/33815/6
|
||||||
cooking_options = post.cooking_options || opts[:cooking_options] || {}
|
@cooking_options = post.cooking_options || opts[:cooking_options] || {}
|
||||||
cooking_options[:topic_id] = post.topic_id
|
@cooking_options[:topic_id] = post.topic_id
|
||||||
@doc = Nokogiri::HTML::fragment(post.cook(post.raw, cooking_options.symbolize_keys))
|
@cooking_options = @cooking_options.symbolize_keys
|
||||||
|
@doc = Nokogiri::HTML::fragment(post.cook(post.raw, @cooking_options))
|
||||||
@size_cache = {}
|
@size_cache = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -266,6 +268,11 @@ class CookedPostProcessor
|
|||||||
|
|
||||||
# make sure we grab dimensions for oneboxed images
|
# make sure we grab dimensions for oneboxed images
|
||||||
oneboxed_images.each { |img| limit_size!(img) }
|
oneboxed_images.each { |img| limit_size!(img) }
|
||||||
|
|
||||||
|
# respect nofollow admin settings
|
||||||
|
if !@cooking_options[:omit_nofollow] && SiteSetting.add_rel_nofollow_to_user_content
|
||||||
|
PrettyText.add_rel_nofollow_to_user_content(@doc)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def optimize_urls
|
def optimize_urls
|
||||||
|
@ -156,4 +156,3 @@ module Oneboxer
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user