mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:41:24 +08:00
FIX: strip spoilers in notification excerpts
This commit is contained in:
@ -17,6 +17,7 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
||||
@keep_emoji_images = options[:keep_emoji_images] == true
|
||||
@keep_onebox_source = options[:keep_onebox_source] == true
|
||||
@remap_emoji = options[:remap_emoji] == true
|
||||
@strip_spoilers = options[:strip_spoilers] == true
|
||||
@start_excerpt = false
|
||||
@in_details_depth = 0
|
||||
@summary_contents = ""
|
||||
@ -110,7 +111,11 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
||||
end
|
||||
# Preserve spoilers
|
||||
if attributes.include?(["class", "spoiler"])
|
||||
include_tag("span", attributes)
|
||||
if @strip_spoilers
|
||||
characters("[#{I18n.t 'excerpt_spoiler'}]")
|
||||
else
|
||||
include_tag("span", attributes)
|
||||
end
|
||||
@in_spoiler = true
|
||||
end
|
||||
|
||||
@ -194,6 +199,8 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
||||
|
||||
@excerpt << before_string if before_string
|
||||
|
||||
string = "" if @in_spoiler && @strip_spoilers
|
||||
|
||||
encode = encode ? lambda { |s| ERB::Util.html_escape(s) } : lambda { |s| s }
|
||||
if count_it && @current_length + string.length > @length
|
||||
length = [0, @length - @current_length - 1].max
|
||||
|
Reference in New Issue
Block a user