Merge pull request #1087 from ZogStriP/fix-posts-rebake
Fix posts rebake
This commit is contained in:
commit
d9a8419d68
|
@ -109,7 +109,8 @@ Discourse.Markdown = {
|
|||
|
||||
// Extract quotes so their contents are not passed through markdown.
|
||||
converter.hooks.chain("preConversion", function(text) {
|
||||
var extracted = Discourse.BBCode.extractQuotes(text);
|
||||
var formated = Discourse.BBCode.format(text, opts);
|
||||
var extracted = Discourse.BBCode.extractQuotes(formated);
|
||||
quoteTemplate = extracted.template;
|
||||
return extracted.text;
|
||||
});
|
||||
|
@ -184,7 +185,7 @@ Discourse.Markdown = {
|
|||
text = quoteTemplate(text);
|
||||
}
|
||||
|
||||
return Discourse.BBCode.format(text, opts);
|
||||
return text;
|
||||
});
|
||||
|
||||
if (opts.sanitize) {
|
||||
|
|
|
@ -181,6 +181,7 @@ class CookedPostProcessor
|
|||
def is_valid_image_uri?(url)
|
||||
uri = URI.parse(url)
|
||||
%w(http https).include? uri.scheme
|
||||
rescue URI::InvalidURIError
|
||||
end
|
||||
|
||||
def dirty?
|
||||
|
|
|
@ -190,6 +190,10 @@ describe CookedPostProcessor do
|
|||
cpp.is_valid_image_uri?("/tmp/image.png").should == false
|
||||
end
|
||||
|
||||
it "doesn't throw exception with a bad URI" do
|
||||
cpp.is_valid_image_uri?("http://do<main.com").should == nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -68,14 +68,14 @@ test("Links", function() {
|
|||
test("Quotes", function() {
|
||||
cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2",
|
||||
{ topicId: 2, lookupAvatar: function(name) { return "" + name; } },
|
||||
"<p>1</p><aside class='quote' data-post=\"1\" >\n <div class='title'>\n <div class='quote-controls'></div>\n" +
|
||||
" bob\n bob\n said:\n </div>\n <blockquote>my quote</blockquote>\n</aside>\n<p> <br>\n2</p>",
|
||||
"<p>1</p><aside class='quote' data-post=\"1\" > <br>\n <div class='title'>\n <div class='quote-controls'></div>\n" +
|
||||
" bob\n bob\n said:\n </div>\n <blockquote>my quote</blockquote>\n</aside> <br>\n<p>2</p>",
|
||||
"handles quotes properly");
|
||||
|
||||
cookedOptions("1[quote=\"bob, post:1\"]my quote[/quote]2",
|
||||
{ topicId: 2, lookupAvatar: function(name) { } },
|
||||
"<p>1</p><aside class='quote' data-post=\"1\" >\n <div class='title'>\n <div class='quote-controls'></div>\n" +
|
||||
" \n bob\n said:\n </div>\n <blockquote>my quote</blockquote>\n</aside>\n<p> <br>\n2</p>",
|
||||
"<p>1</p><aside class='quote' data-post=\"1\" > <br>\n <div class='title'>\n <div class='quote-controls'></div></p>\n" +
|
||||
"\n<p>bob\n said:\n </div>\n <blockquote>my quote</blockquote>\n</aside> <br>\n<p>2</p>",
|
||||
"includes no avatar if none is found");
|
||||
});
|
||||
|
||||
|
@ -118,4 +118,10 @@ test("SanitizeHTML", function() {
|
|||
equal(sanitizeHtml("<div><script>alert('hi');</script></div>"), "<div></div>");
|
||||
equal(sanitizeHtml("<div><p class=\"funky\" wrong='1'>hello</p></div>"), "<div><p class=\"funky\">hello</p></div>");
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
test("with BBCode", function() {
|
||||
cooked("[img]http://eviltrout.com/eviltrout.png[/img]",
|
||||
"<p><img src=\"http://eviltrout.com/eviltrout.png\"></p>",
|
||||
"BBCode is parsed first");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue