Skip to content

Commit

Permalink
filter_html in notextile block
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Garber authored and Jason Garber committed Jul 1, 2008
1 parent 3ce4407 commit 8e8b400
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
43 changes: 23 additions & 20 deletions ext/redcloth_scan/redcloth_scan.rl
Expand Up @@ -121,27 +121,30 @@ int SYM_escape_preformatted;
*|;

notextile_block := |*
EOF {
DONE(block);
fgoto main;
EOF {
ADD_BLOCK();
fgoto main;
};
double_return {
if (NIL_P(extend)) {
DONE(block);
fgoto main;
} else {
CAT(block);
DONE(block);
}
double_return {
if (NIL_P(extend)) {
ADD_BLOCK();
CAT(html);
fgoto main;
} else {
CAT(block);
ADD_EXTENDED_BLOCK();
CAT(html);
}
};
double_return next_block_start {
if (NIL_P(extend)) {
DONE(block);
fgoto main;
} else {
CAT(block);
DONE(block);
END_EXTENDED();
double_return next_block_start {
if (NIL_P(extend)) {
ADD_BLOCK();
CAT(html);
fgoto main;
} else {
CAT(block);
ADD_EXTENDED_BLOCK();
END_EXTENDED();
fgoto main;
}
};
Expand Down Expand Up @@ -274,7 +277,7 @@ int SYM_escape_preformatted;
main := |*
noparagraph_line_start { ASET(type, ignored_line); fgoto noparagraph_line; };
notextile_tag_start { ASET(type, notextile); fgoto notextile_tag; };
notextile_block_start { fgoto notextile_block; };
notextile_block_start { ASET(type, notextile); fgoto notextile_block; };
script_tag_start { CAT(block); fgoto script_tag; };
pre_tag_start { ASET(type, notextile); CAT(block); fgoto pre_tag; };
pre_block_start { fgoto pre_block; };
Expand Down
16 changes: 16 additions & 0 deletions test/filter_html.yml
Expand Up @@ -82,6 +82,22 @@ in: |-
filtered_html: |-
<p>I have some <code>&lt;em&gt;awesome&lt;/em&gt; code</code> here.</p>
---
name: escapes html notextile block
in: |-
notextile. This is a <em>notextile</em> block.
filtered_html: |-
This is a &lt;em&gt;notextile&lt;/em&gt; block.
---
name: escapes html in pre tags
in: |-
<pre>
This should be <em>escaped</em>.
</pre>
filtered_html: |-
<pre>
This should be &lt;em&gt;escaped&lt;/em&gt;.
</pre>
---
in: Here's a bad image <img src="JaVaScRiPt:alert('XSS');">
filtered_html: <p>Here&#8217;s a bad image &lt;img src="JaVaScRiPt:alert('XSS');"&gt;</p>
---
Expand Down

0 comments on commit 8e8b400

Please sign in to comment.