diff --git a/_plugins/safe_post_html.rb b/_plugins/safe_post_html.rb new file mode 100644 index 0000000..6f1b598 --- /dev/null +++ b/_plugins/safe_post_html.rb @@ -0,0 +1,86 @@ +# frozen_string_literal: true +# +# Fails the build when a post's rendered body holds markup that would run code +# in a reader's browser or load another document in the site's origin: an +# active element (", + '', + "", + 'x', + 'x', + "x", + 'x', + '', + '', + "", + '
', + '', + '', + '', + "

p

" + ].freeze + + def test_each_way_markup_can_run_code_is_reported + ACTIVE.each do |html| + refute_empty SafePostHtml.violations("

x

#{html}"), html + end + end + + SAFE = [ + '그림', + '', + '점', + '안내', + '위로', + '글', + '메일', + '전화', + '', + '
<script>alert(1)</script> <img onerror=x>
', + 't' + ].freeze + + def test_what_posts_carry_is_not_reported + SAFE.each do |html| + assert_empty SafePostHtml.violations(html), html + end + end +end