Skip to content

Commit

Permalink
Backport Upskirt changes for HTML filtering
Browse files Browse the repository at this point in the history
Filtered HTML now disappears from the rendered document, instead of
appearing with escaped HTML entities.
  • Loading branch information
vmg committed May 1, 2011
1 parent 287a8b7 commit 16b0562
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
25 changes: 10 additions & 15 deletions ext/xhtml.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,23 +437,20 @@ static int
rndr_raw_html(struct buf *ob, struct buf *text, void *opaque)
{
struct xhtml_renderopt *options = opaque;
int escape_html = 0;

if ((options->flags & XHTML_SKIP_STYLE) != 0 && is_html_tag(text, "style"))
escape_html = 1;
if ((options->flags & XHTML_SKIP_HTML) != 0)
return 1;

else if ((options->flags & XHTML_SKIP_LINKS) != 0 && is_html_tag(text, "a"))
escape_html = 1;
if ((options->flags & XHTML_SKIP_STYLE) != 0 && is_html_tag(text, "style"))
return 1;

else if ((options->flags & XHTML_SKIP_IMAGES) != 0 && is_html_tag(text, "img"))
escape_html = 1;
if ((options->flags & XHTML_SKIP_LINKS) != 0 && is_html_tag(text, "a"))
return 1;

if ((options->flags & XHTML_SKIP_IMAGES) != 0 && is_html_tag(text, "img"))
return 1;

if (escape_html)
attr_escape(ob, text->data, text->size);
else
bufput(ob, text->data, text->size);

bufput(ob, text->data, text->size);
return 1;
}

Expand Down Expand Up @@ -785,10 +782,8 @@ ups_xhtml_renderer(struct mkd_renderer *renderer, unsigned int render_flags)
renderer->autolink = NULL;
}

if (render_flags & XHTML_SKIP_HTML) {
renderer->raw_html_tag = NULL;
if (render_flags & XHTML_SKIP_HTML)
renderer->blockhtml = NULL;
}

if (render_flags & XHTML_SMARTYPANTS)
renderer->normal_text = rndr_smartypants;
Expand Down
2 changes: 1 addition & 1 deletion lib/redcarpet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# end
#
class Redcarpet
VERSION = '1.12.1'
VERSION = '1.12.2'

# Original Markdown formatted text.
attr_reader :text
Expand Down
2 changes: 1 addition & 1 deletion redcarpet.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'redcarpet'
s.version = '1.12.1'
s.version = '1.12.2'
s.summary = "Ruby bindings for libupskirt"
s.description = 'A fast and safe Markdown to (X)HTML parser'
s.date = '2011-05-01'
Expand Down
2 changes: 1 addition & 1 deletion test/markdown_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_that_inline_markdown_starts_and_ends_correctly

def test_that_filter_html_works
markdown = Markdown.new('Through <em>NO</em> <script>DOUBLE NO</script>', :filter_html)
html_equal "<p>Through &lt;em>NO&lt;/em> &lt;script>DOUBLE NO&lt;/script></p>", markdown.to_html.strip
html_equal "<p>Through NO DOUBLE NO</p>", markdown.to_html.strip
end

def test_that_bluecloth_restrictions_are_supported
Expand Down
2 changes: 1 addition & 1 deletion upskirt
Submodule upskirt updated from c7c76b to e2a306

0 comments on commit 16b0562

Please sign in to comment.