FIX: blank cooked markdown could raise an exception in logs

Previously if somehow a user created a blank markdown document using tag
tricks (eg `<p></p><p></p><p></p><p></p><p></p><p></p>`) and so on, we would
completely strip the document down to blank on post process due to onebox
hack.

Needs a followup cause I am still unclear about the reason for empty p stripping
and it can cause some unclear cases when we re-cook posts.
This commit is contained in:
Sam Saffron
2020-01-29 11:37:04 +11:00
parent ab3bda6cd0
commit 7f3a30d79f
3 changed files with 14 additions and 2 deletions

View File

@@ -23,7 +23,8 @@ class CookedPostProcessor
@cooking_options[:topic_id] = post.topic_id
@cooking_options = @cooking_options.symbolize_keys
@doc = Nokogiri::HTML::fragment(post.cook(post.raw, @cooking_options))
cooked = post.cook(post.raw, @cooking_options)
@doc = Nokogiri::HTML::fragment(cooked)
@has_oneboxes = post.post_analyzer.found_oneboxes?
@size_cache = {}