mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: Remove full nested quotes on direct reply (#8581)
It used to check how many quotes were inside a post, without taking considering that some quotes can contain other quotes. This commit selects only top level quotes. I had to use XPath because I could not find an equivalent CSS selector.
This commit is contained in:
@ -83,7 +83,7 @@ class CookedPostProcessor
|
||||
def remove_full_quote_on_direct_reply
|
||||
return if !SiteSetting.remove_full_quote
|
||||
return if @post.post_number == 1
|
||||
return if @doc.css("aside.quote").size != 1
|
||||
return if @doc.xpath("aside[contains(@class, 'quote')]").size != 1
|
||||
|
||||
previous = Post
|
||||
.where("post_number < ? AND topic_id = ? AND post_type = ? AND NOT hidden", @post.post_number, @post.topic_id, Post.types[:regular])
|
||||
@ -99,7 +99,7 @@ class CookedPostProcessor
|
||||
|
||||
return if previous_text.gsub(/(\s){2,}/, '\1') != quoted_text.gsub(/(\s){2,}/, '\1')
|
||||
|
||||
quote_regexp = /\A\s*\[quote.+?\[\/quote\]/im
|
||||
quote_regexp = /\A\s*\[quote.+\[\/quote\]/im
|
||||
quoteless_raw = @post.raw.sub(quote_regexp, "").strip
|
||||
|
||||
return if @post.raw.strip == quoteless_raw
|
||||
|
Reference in New Issue
Block a user