fixes #530
This commit is contained in:
@@ -19,7 +19,18 @@
|
||||
}
|
||||
|
||||
Danbooru.Comment.quote_message = function(data) {
|
||||
var stripped_body = data["body"].replace(/\[quote\](?:.|\n|\r)+?\[\/quote\](?:\r\n|\r|\n)*/gm, "");
|
||||
var blocks = data["body"].match(/\[\/?quote\]|./gm);
|
||||
var n = 0;
|
||||
var stripped_body = "";
|
||||
$.each(blocks, function(i, block) {
|
||||
if (block === "[quote]") {
|
||||
n += 1;
|
||||
} else if (block == "[/quote]") {
|
||||
n -= 1;
|
||||
} else if (n === 0) {
|
||||
stripped_body += block;
|
||||
}
|
||||
});
|
||||
return "[quote]\n" + data["creator_name"] + " said:\n\n" + stripped_body + "\n[/quote]\n\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,28 @@ class DText
|
||||
CGI.escapeHTML(string)
|
||||
end
|
||||
|
||||
def self.strip_blocks(string, tag)
|
||||
blocks = string.scan(/\[\/?#{tag}\]|.+?(?=\[\/?#{tag}\]|$)/m)
|
||||
n = 0
|
||||
stripped = ""
|
||||
blocks.each do |block|
|
||||
case block
|
||||
when "[#{tag}]"
|
||||
n += 1
|
||||
|
||||
when "[/#{tag}]"
|
||||
n -= 1
|
||||
|
||||
else
|
||||
if n == 0
|
||||
stripped += block
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
stripped.strip
|
||||
end
|
||||
|
||||
def self.parse_inline(str, options = {})
|
||||
str.gsub!(/&/, "&")
|
||||
str.gsub!(/</, "<")
|
||||
|
||||
@@ -149,7 +149,7 @@ class ForumPost < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def quoted_response
|
||||
stripped_body = body.gsub(/\[quote\](?:.|\n|\r)+?\[\/quote\][\n\r]*/m, "")
|
||||
stripped_body = DText.strip_blocks(body, "quote")
|
||||
"[quote]\n#{creator_name} said:\n\n#{stripped_body}\n[/quote]\n\n"
|
||||
end
|
||||
|
||||
|
||||
@@ -547,7 +547,7 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def has_dup_tag?
|
||||
has_tag?("duplicate") ? true : false
|
||||
has_tag?("duplicate")
|
||||
end
|
||||
|
||||
def tag_categories
|
||||
|
||||
Reference in New Issue
Block a user