8000 Use sanitization filter in tests · github/markup@ebe8e64 · GitHub
[go: up one dir, main page]

Skip to content

Commit ebe8e64

Browse files
committed
Use sanitization filter in tests
1 parent ef25634 commit ebe8e64

14 files changed

+198
-174
lines changed

test/markup_test.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ class MarkupTest < Minitest::Test
1010
class MarkupFilter < HTML::Pipeline::Filter
1111
def call
1212
filename = context[:filename]
13-
GitHub::Markup.render(filename, File.read(filename)).rstrip.force_encoding("utf-8")
13+
GitHub::Markup.render(filename, File.read(filename)).strip.force_encoding("utf-8")
1414
end
1515
end
1616

1717
Pipeline = HTML::Pipeline.new [
18-
MarkupFilter
18+
MarkupFilter,
19+
HTML::Pipeline::SanitizationFilter
1920
]
2021

2122
Dir['test/markups/README.*'].each do |readme|

test/markups/README.asciidoc.html

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<h1>Document Title</h1>
2-
<div class="sect1">
3-
<h2 id="first-section">First Section</h2>
4-
<div class="sectionbody">
5-
<div class="ulist">
2+
<div>
3+
<h2>First Section</h2>
4+
<div>
5+
<div>
66
<ul>
77
<li>
88
<p>One</p>
@@ -14,26 +14,25 @@ <h2 id="first-section">First Section</h2>
1414
</div>
1515
</div>
1616
</div>
17-
<div class="sect1">
18-
<h2 id="second-section">Second Section</h2>
19-
<div class="sectionbody">
20-
<div class="admonitionblock note">
17+
<div>
18+
<h2>Second Section</h2>
19+
<div>
20+
<div>
2121
<table>
2222
<tr>
23-
<td class="icon">
24-
<div class="title">Note</div>
23+
<td>
24+
<div>Note</div>
2525
</td>
26-
<td class="content">
26+
<td>
2727
Here is some source code.
2828
</td>
2929
</tr>
3030
</table>
3131
</div>
32-
<div class="listingblock">
33-
<div class="content">
32+
<div>
33+
<div>
3434
<pre lang="ruby"><code>puts "Hello, World!"</code></pre>
3535
</div>
3636
</div>
3737
</div>
38-
</div>
39-
38+
</div>

test/markups/README.creole.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<h1>H1</h1><h2>H2</h2><p>paragraph of text that will be turned into a paragraph element. It can go over several lines with line breaks, it will be turned into a contiguous paragraph element.</p><p>You can force a linebreak in your paragraph text<br/>thusly.</p><ul><li>a list element<ul><li>sub list element</li></ul></li><li>2nd list element</li></ul><pre>pre formatted text
1+
<h1>H1</h1><h2>H2</h2><p>paragraph of text that will be turned into a paragraph element. It can go over several lines with line breaks, it will be turned into a contiguous paragraph element.</p><p>You can force a linebreak in your paragraph text<br>thusly.</p><ul>
2+
<li>a list element<ul><li>sub list element</li></ul>
3+
</li>
4+
<li>2nd list element</li>
5+
</ul><pre>pre formatted text
26

37
$ ls -la
48
total 56

test/markups/README.litcoffee.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ <h2>Literate CoffeeScript Test</h2>
66

77
<p>comment comment</p>
88

9-
<pre><code>test &quot;basic literate CoffeeScript parsing&quot;, -&gt;
9+
<pre><code>test "basic literate CoffeeScript parsing", -&gt;
1010
ok yes
1111
</code></pre>
1212

1313
<p>now with a...</p>
1414

15-
<pre><code>test &quot;broken up indentation&quot;, -&gt;
15+
<pre><code>test "broken up indentation", -&gt;
1616
</code></pre>
1717

1818
<p>... broken up ...</p>
@@ -27,7 +27,7 @@ <h2>Literate CoffeeScript Test</h2>
2727

2828
<p>Code must be separated from text by a blank line.</p>
2929

30-
<pre><code>test &quot;code blocks must be preceded by a blank line&quot;, -&gt;
30+
<pre><code>test "code blocks must be preceded by a blank line", -&gt;
3131
</code></pre>
3232

3333
<p>The next line is part of the text and will not be executed.
@@ -38,7 +38,7 @@ <h2>Literate CoffeeScript Test</h2>
3838

3939
<p>Code in <code>backticks is not parsed</code> and...</p>
4040

41-
<pre><code>test &quot;comments in indented blocks work&quot;, -&gt;
41+
<pre><code>test "comments in indented blocks work", -&gt;
4242
do -&gt;
4343
do -&gt;
4444
# Regular comment.
@@ -62,5 +62,5 @@ <h2>Literate CoffeeScript Test</h2>
6262

6363
<p>Tabs work too:</p>
6464

65-
<p>test &quot;tabbed code&quot;, -&gt;
66-
ok yes</p>
65+
<p>test "tabbed code", -&gt;
66+
ok yes</p>

test/markups/README.markdown.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<ul>
22
<li>One</li>
33
<li>Two</li>
4-
</ul>
4+
</ul>

test/markups/README.mediawiki.html

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
1-
2-
<p><a href="Home">&raquo; JRuby Project Wiki Home Page</a>
3-
<h1>Embedding JRuby</h1>
1+
<p><a href="Home">» JRuby Project Wiki Home Page</a>
2+
</p><h1>Embedding JRuby</h1>
43
Using Java from Ruby is JRuby's best-known feature---but you can also go in the other direction, and use Ruby from Java. There are several different ways to do this. You can execute entire Ruby scripts, call individual Ruby methods, or even implement a Java interface in Ruby (thus allowing you to treat Ruby objects like Java ones). We refer to all these techniques generically as "embedding." This section will explain how to embed JRuby in your Java project.
5-
</p>
6-
<p><table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Table of Contents</h2></div><ul></li><li>< F438 a href="#Red_Bridge_JRuby_Embed">Red Bridge (JRuby Embed)</a><ul><li><a href="#Features_of_Red_Bridge">Features of Red Bridge</a></li></ul><li><a href="#Previous_Embedding_JRuby_Page">Previous Embedding JRuby Page</a></li><li><a href="#References">References</a></li></ul></td></tr></table>
7-
</p>
84

9-
<h1><a name="Red_Bridge_JRuby_Embed"></a><span class="mw-headline" id="Red_Bridge_JRuby_Embed">Red Bridge (JRuby Embed)</span></h1>
5+
<p></p><table summary="Contents"><tr><td>
6+
<div><h2>Table of Contents</h2></div>
7+
<ul>
8+
<li>
9+
<a href="#Red_Bridge_JRuby_Embed">Red Bridge (JRuby Embed)</a><ul><li><a href="#Features_of_Red_Bridge">Features of Red Bridge</a></li></ul>
10+
</li>
11+
<li><a href="#Previous_Embedding_JRuby_Page">Previous Embedding JRuby Page</a></li>
12+
<li><a href="#References">References</a></li>
13+
</ul>
14+
</td></tr></table>
15+
16+
17+
<h1>
18+
<a name="Red_Bridge_JRuby_Embed"></a>Red Bridge (JRuby Embed)</h1>
1019

1120

1221

1322
<p>JRuby has long had a private embedding API, which was closely tied to the runtime's internals and therefore changed frequently as JRuby evolved. Since version 1.4, however, we have also provided a more stable public API, known as Red Bridge or JRuby Embed. Existing Java programs written to the <a href="DirectJRubyEmbedding">legacy API</a> should still work, but we strongly recommend Red Bridge for all new projects.
1423
</p>
1524

16-
<h2><a name="Features_of_Red_Bridge"></a><span class="mw-headline" id="Features_of_Red_Bridge">Features of Red Bridge</span></h2>
25+
<h2>
26+
<a name="Features_of_Red_Bridge"></a>Features of Red Bridge</h2>
1727

1828

1929
<p>Red Bridge consists of two layers: Embed Core on the bottom, and implementations of <a href="http://www.jcp.org/en/jsr/detail?id=223" target="_blank">JSR223</a> and <a href="http://jakarta.apache.org/bsf/" target="_blank">BSF</a> on top. Embed Core is JRuby-specific, and can take advantage of much of JRuby's power. JSR223 and BSF are more general interfaces that provide a common ground across scripting languages.
@@ -23,19 +33,25 @@ <h2><a name="Features_of_Red_Bridge"></a><span class="mw-headline" id="Features_
2333

2434

2535

26-
<p><ol><li>With Embed Core, you can create several Ruby environments in one JVM, and configure them individually (via <code>org.jruby.RubyInstanceConfig</code>. With the other APIs, configuration options can only be set globally, via the <code>System</code> properties.</li><li>Embed Core offers several shortcuts, such as loading scripts from a <code>java.io.InputStream</code>, or returning Java-friendly objects from Ruby code. These allow you to skip a lot of boilerplate.</li></ol>
36+
<p></p><ol>
37+
<li>With Embed Core, you can create several Ruby environments in one JVM, and configure them individually (via <code>org.jruby.RubyInstanceConfig</code>. With the other APIs, configuration options can only be set globally, via the <code>System</code> properties.</li>
38+
<li>Embed Core offers several shortcuts, such as loading scripts from a <code>java.io.InputStream</code>, or returning Java-frien 10000 dly objects from Ruby code. These allow you to skip a lot of boilerplate.</li>
39+
</ol>
2740
For projects requiring multiple scripting languages, JSR223 is a good fit. Though the API is language-independent, JRuby's implementation of it allows you to set some Ruby-specific options. In particular, you can control the threading model of the scripting engine, the lifetime of local variables, compilation mode, and how line numbers are displayed.
28-
</p>
41+
2942
<p>The full <a href="http://jruby-embed.kenai.com/docs/" target="_blank">API documentation</a> has all the gory details. It's worth talking about a couple of the finer points here.
3043
</p>
3144

32-
<h1><a name="Previous_Embedding_JRuby_Page"></a><span class="mw-headline" id="Previous_Embedding_JRuby_Page">Previous Embedding JRuby Page</span></h1>
45+
<h1>
46+
<a name="Previous_Embedding_JRuby_Page"></a>Previous Embedding JRuby Page</h1>
3347

3448

35-
<p>We recommend using Embed Core; however, if you're maintaining code that uses the old API, you can find its documentation on the <a href="JavaIntegration">legacy embedding</a><sup class="reference" id="cite_ref-1-0">[<a href="#cite_note-1">1</a>]</sup> page.
49+
<p>We recommend using Embed Core; however, if you're maintaining code that uses the old API, you can find its documentation on the <a href="JavaIntegration">legacy embedding</a><sup>[<a href="#cite_note-1">1</a>]</sup> page.
3650
</p>
3751

38-
<h1><a name="References"></a><span class="mw-headline" id="References">References</span></h1>
52+
<h1>
53+
<a name="References"></a>References</h1>
3954

4055

41-
<p><ol><li id="cite_note-1"><b><a href="#cite_ref-1-0">^</a> </b> This link goes nowhere.</li></ol></p>
56+
<p></p><ol><li>
57+
<b><a href="#cite_ref-1-0">^</a> </b> This link goes nowhere.</li></ol>

test/markups/README.noformat.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
* One
2-
* Two
2+
* Two

test/markups/README.org.html

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,47 @@
1-
<h1 class="title">org-ruby</h1>
1+
<h1>org-ruby</h1>
22
<table>
3-
<tr><td>Status:</td><td>Under Development</td></tr>
4-
<tr><td>Location:</td><td><a href="http://github.com/wallyqs/org-ruby">http://github.com/wallyqs/org-ruby</a></td></tr>
5-
<tr><td>Version:</td><td>0.9.0</td></tr>
3+
<tr>
4+
<td>Status:</td>
5+
<td>Under Development</td>
6+
</tr>
7+
<tr>
8+
<td>Location:</td>
9+
<td><a href="http://github.com/wallyqs/org-ruby">http://github.com/wallyqs/org-ruby</a></td>
10+
</tr>
11+
<tr>
12+
<td>Version:</td>
13+
<td>0.9.0</td>
14+
</tr>
615
</table>
7-
<h1><span class="heading-number heading-number-1">1</span> Description</h1>
16+
<h1>1 Description</h1>
817
<p>Helpful Ruby routines for parsing orgmode files. The most
918
significant thing this library does today is convert orgmode files
1019
to textile. Currently, you cannot do much to customize the
1120
conversion. The supplied textile conversion is optimized for
12-
extracting &#8220;content&#8221; from the orgfile as opposed to &#8220;metadata.&#8221;</p>
13-
<h1><span class="heading-number heading-number-1">2</span> History</h1>
14-
<h2><span class="heading-number heading-number-2">2.1</span> 2014-02-08: Version 0.9.0</h2>
21+
extracting content from the orgfile as opposed to metadata.</p>
22+
<h1>2 History</h1>
23+
<h2>2.1 2014-02-08: Version 0.9.0</h2>
1524
<ul>
16-
<li>Let&#8217;s make sure <code>#+INCLUDE:</code> is not supported</li>
25+
<li>Lets make sure <code>#+INCLUDE:</code> is not supported</li>
1726
</ul>
1827
<ul>
1928
<li>And confirm that syntax highlight is supported</li>
2029
</ul>
21-
<pre class="src" lang="ruby">
30+
<pre lang="ruby">
2231
module GitHub
2332
module Markup
24-
VERSION = &#39;test&#39;
33+
VERSION = 'test'
2534
Version = VERSION
2635
end
2736
end
2837
</pre>
29-
<h2><span class="heading-number heading-number-2">2.2</span> 2009-12-30: Version 0.5.1</h2>
38+
<h2>2.2 2009-12-30: Version 0.5.1</h2>
3039
<ul>
31-
<li>Minor enhancement: Recognize lines starting with &#8220;:&#8221; as examples.</li>
40+
<li>Minor enhancement: Recognize lines starting with “:” as examples.</li>
3241
<li>Minor enhancement: Recognize #+BEGIN_SRC as source blocks</li>
33-
<li>Minor enhancement: Add &#8220;src&#8221; and &#8220;example&#8221; classes to &lt;pre&gt; blocks.</li>
42+
<li>Minor enhancement: Add src and example classes to &lt;pre&gt; blocks.</li>
3443
</ul>
35-
<h2><span class="heading-number heading-number-2">2.3</span> 2009-12-30: Version 0.5.0</h2>
44+
<h2>2.3 2009-12-30: Version 0.5.0</h2>
3645
<ul>
3746
<li>Parse (but not necessarily <b>use</b>) in-buffer settings. The following
3847
in-buffer settings <b>are</b> used:
@@ -47,7 +56,7 @@ <h2><span class="heading-number heading-number-2">2.3</span> 2009-12-30: Version
4756
the tree to export</li>
4857
</ul>
4958
</li>
50-
<li>Rewrite &#8220;file:(blah).org&#8221; links to &#8220;http:(blah).html&#8221; links. This
59+
<li>Rewrite file:(blah).org links to http:(blah).html links. This
5160
makes the inter-links to other org-mode files work.</li>
5261
<li>Uses &lt;th&gt; tags inside table rows that precede table separators.</li>
5362
<li>Bugfixes:
@@ -56,7 +65,7 @@ <h2><span class="heading-number heading-number-2">2.3</span> 2009-12-30: Version
5665
</ul>
5766
</li>
5867
</ul>
59-
<h2><span class="heading-number heading-number-2">2.4</span> 2009-12-29: Version 0.4.2</h2>
68+
<h2>2.4 2009-12-29: Version 0.4.2</h2>
6069
<ul>
6170
<li>Got rid of the extraneous newline at the start of code blocks.</li>
6271
<li>Everything now shows up in code blocks, even org-mode metadata.</li>
@@ -67,64 +76,64 @@ <h2><span class="heading-number heading-number-2">2.4</span> 2009-12-29: Version
6776
</ul>
6877
</li>
6978
</ul>
70-
<h2><span class="heading-number heading-number-2">2.5</span> 2009-12-29: Version 0.4.1</h2>
79+
<h2>2.5 2009-12-29: Version 0.4.1</h2>
7180
<ul>
7281
<li>HTML is now escaped by default</li>
7382
<li>org-mode comments will show up in a code block.</li>
7483
</ul>
75-
<h2><span class="heading-number heading-number-2">2.6</span> 2009-12-29: Version 0.4</h2>
84+
<h2>2.6 2009-12-29: Version 0.4</h2>
7685
<ul>
77-
<li>The first thing output in HTML gets the class &#8220;title&#8221;</li>
86+
<li>The first thing output in HTML gets the class title</li>
7887
<li>HTML output is now indented</li>
7988
<li>Proper support for multi-paragraph list items.
8089
<p>See? This paragraph is part of the last bullet.</p>
8190
</li>
8291
<li>Fixed bugs:
8392
<ul>
84-
<li>&#8220;rake spec&#8221; wouldn&#8217;t work on Linux. Needed &#8220;require &#8216;rubygems&#8217;&#8221;.</li>
93+
<li>rake spec wouldnt work on Linux. Needed require rubygems’”.</li>
8594
</ul>
8695
</li>
8796
</ul>
88-
<h2><span class="heading-number heading-number-2">2.7</span> 2009-12-27: Version 0.3</h2>
97+
<h2>2.7 2009-12-27: Version 0.3</h2>
8998
<ul>
90-
<li>Uses rubypants to get better typography (smart quotes, elipses, etc&#8230;).</li>
99+
<li>Uses rubypants to get better typography (smart quotes, elipses, etc).</li>
91100
<li>Fixed bugs:
92101
<ul>
93102
<li>Tables and lists did not get properly closed at the end of file</li>
94-
<li>You couldn&#8217;t do inline formatting inside table cells</li>
103+
<li>You couldnt do inline formatting inside table cells</li>
95104
<li>Characters in PRE blocks were not HTML escaped.</li>
96105
</ul>
97106
</li>
98107
</ul>
99-
<h2><span class="heading-number heading-number-2">2.8</span> 2009-12-26: Version 0.2</h2>
108+
<h2>2.8 2009-12-26: Version 0.2</h2>
100109
<ul>
101110
<li>Added <code>to_html</code> output on the parser.</li>
102111
<li>Added support for the full range of inline markup: <b>bold</b>,
103-
<i>italic</i>, <code>code</code>, <code>verbatim</code>, <span style="text-decoration:underline;">underline</span>, <del>strikethrough</del>.</li>
112+
<i>italic</i>, <code>code</code>, <code>verbatim</code>, underline, <del>strikethrough</del>.</li>
104113
<li>Lots of refactoring to make the code more maintainable.</li>
105114
</ul>
106-
<h2><span class="heading-number heading-number-2">2.9</span> 2009-12-23: Version 0.1</h2>
115+
<h2>2.9 2009-12-23: Version 0.1</h2>
107116
<ul>
108117
<li>Added support for block code, like this:
109-
<pre class="example">
118+
<pre>
110119
def flush!
111-
@logger.debug &quot;FLUSH ==========&gt; #{@output_type}&quot;
120+
@logger.debug "FLUSH ==========&gt; #{@output_type}"
112121
if (@output_type == :blank) then
113-
@output &lt;&lt; &quot;\n&quot;
122+
@output &lt;&lt; "\n"
114123
elsif (@buffer.length &gt; 0) then
115124
if @cancel_modifier then
116-
@output &lt;&lt; &quot;p. &quot; if @output_type == :paragraph
125+
@output &lt;&lt; "p. " if @output_type == :paragraph
117126
@cancel_modifier = false
118127
end
119128
@output &lt;&lt; @paragraph_modifier if (@paragraph_modifier and not sticky_modifier?)
120-
@output &lt;&lt; @buffer.textile_substitution &lt;&lt; &quot;\n&quot;
129+
@output &lt;&lt; @buffer.textile_substitution &lt;&lt; "\n"
121130
end
122-
@buffer = &quot;&quot;
131+
@buffer = ""
123132
end
124133
</pre>
125134
</li>
126135
<li>Major code cleanup: Created the <code>OutputBuffer</code> class that
127136
greatly simplified a lot of the messiness of <code>textile</code>
128137
conversion.</li>
129138
<li>Added support for line breaks within list items.</li>
130-
</ul>
139+
</ul>

0 commit comments

Comments
 (0)
0