aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test-markdown.py8
-rw-r--r--tests/markdown-test/benchmark.dat38
-rw-r--r--tests/misc/benchmark.dat92
-rw-r--r--tests/safe_mode/inline-html-advanced.html14
-rw-r--r--tests/safe_mode/inline-html-advanced.txt14
-rw-r--r--tests/safe_mode/inline-html-comments.html14
-rw-r--r--tests/safe_mode/inline-html-comments.txt13
-rw-r--r--tests/safe_mode/inline-html-simple.html64
-rw-r--r--tests/safe_mode/inline-html-simple.txt69
-rw-r--r--tests/safe_mode/script_tags.html33
-rw-r--r--tests/safe_mode/script_tags.txt33
11 files changed, 328 insertions, 64 deletions
diff --git a/test-markdown.py b/test-markdown.py
index 48dd40b..06696fa 100644
--- a/test-markdown.py
+++ b/test-markdown.py
@@ -5,7 +5,7 @@ import textwrap
markdown = None
TEST_DIR = "tests"
-TMP_DIR = "/tmp/"
+TMP_DIR = "./tmp/"
WRITE_BENCHMARK = True
WRITE_BENCHMARK = False
ACTUALLY_MEASURE_MEMORY = True
@@ -162,7 +162,7 @@ def smart_split(text) :
-def testDirectory(dir, measure_time = False) :
+def testDirectory(dir, measure_time=False, safe_mode=False) :
encoding = "utf8"
@@ -197,7 +197,7 @@ def testDirectory(dir, measure_time = False) :
mem = memory()
t = time.clock()
- md = markdown.Markdown(extensions=extensions)
+ md = markdown.Markdown(extensions=extensions, safe_mode = safe_mode)
construction_time = time.clock() - t
construction_mem = memory(mem)
@@ -353,4 +353,4 @@ testDirectory("tests/markdown-test", measure_time=True)
testDirectory("tests/misc", measure_time=True)
#testDirectory("tests/extensions-x-footnotes")
# testDirectory("tests/extensions-x-ext1-ext2")
-
+testDirectory("tests/safe_mode", measure_time=True, safe_mode="escape")
diff --git a/tests/markdown-test/benchmark.dat b/tests/markdown-test/benchmark.dat
index 5528ebe..5b645ed 100644
--- a/tests/markdown-test/benchmark.dat
+++ b/tests/markdown-test/benchmark.dat
@@ -1,20 +1,20 @@
construction:0.000000:0.000000
-amps-and-angle-encoding:0.100000:0.000000
-auto-links:0.090000:0.000000
-backlash-escapes:0.340000:397312.000000
-blockquotes-with-dode-blocks:0.040000:0.000000
-hard-wrapped:0.040000:0.000000
-horizontal-rules:0.330000:-57344.000000
-inline-html-advanced:0.100000:0.000000
-inline-html-comments:0.120000:0.000000
-inline-html-simple:0.440000:0.000000
-links-inline:0.230000:0.000000
-links-reference:0.290000:0.000000
-literal-quotes:0.090000:0.000000
-markdown-documentation-basics:0.880000:991232.000000
-markdown-syntax:4.020000:2998272.000000
-nested-blockquotes:0.080000:0.000000
-ordered-and-unordered-list:0.490000:0.000000
-strong-and-em-together:0.100000:0.000000
-tabs:0.130000:0.000000
-tidyness:0.090000:0.000000
+amps-and-angle-encoding:0.060000:0.000000
+auto-links:0.070000:135168.000000
+backlash-escapes:0.220000:360448.000000
+blockquotes-with-dode-blocks:0.020000:0.000000
+hard-wrapped:0.010000:0.000000
+horizontal-rules:0.140000:0.000000
+inline-html-advanced:0.060000:0.000000
+inline-html-comments:0.070000:0.000000
+inline-html-simple:0.170000:0.000000
+links-inline:0.100000:0.000000
+links-reference:0.120000:0.000000
+literal-quotes:0.070000:0.000000
+markdown-documentation-basics:0.740000:1175552.000000
+markdown-syntax:3.030000:2596864.000000
+nested-blockquotes:0.100000:0.000000
+ordered-and-unordered-list:0.360000:0.000000
+strong-and-em-together:0.110000:0.000000
+tabs:0.120000:0.000000
+tidyness:0.120000:0.000000
diff --git a/tests/misc/benchmark.dat b/tests/misc/benchmark.dat
index aeaff6f..ac0334c 100644
--- a/tests/misc/benchmark.dat
+++ b/tests/misc/benchmark.dat
@@ -1,46 +1,56 @@
construction:0.000000:0.000000
-adjacent-headers:0.010000:0.000000
+CRLF_line_ends:0.020000:0.000000
+adjacent-headers:0.020000:0.000000
amp-in-url:0.020000:0.000000
ampersand:0.010000:0.000000
-arabic:0.170000:126976.000000
-attributes2:0.030000:0.000000
-bidi:0.450000:110592.000000
-blank-block-quote:0.020000:0.000000
-br:0.050000:0.000000
+arabic:0.110000:0.000000
+attributes2:0.020000:0.000000
+bidi:0.310000:0.000000
+blank-block-quote:0.010000:0.000000
+blockquote:0.090000:0.000000
+blockquote-hr:0.060000:0.000000
+bold_links:0.020000:0.000000
+br:0.040000:0.000000
+bracket_re:7.490000:0.000000
+code-first-line:0.020000:0.000000
comments:0.040000:0.000000
div:0.040000:0.000000
-email:0.040000:0.000000
-funky-list:0.080000:0.000000
-h1:0.030000:0.000000
-hash:0.050000:0.000000
-headers:0.070000:0.000000
-hline:0.040000:0.000000
-html:0.080000:0.000000
-image:0.030000:0.000000
-image-2:0.040000:0.000000
-image_in_links:0.030000:0.000000
-inside_html:0.030000:0.000000
-japanese:0.110000:0.000000
-lists:0.080000:0.000000
-lists2:0.030000:0.000000
-lists3:0.030000:0.000000
-lists4:0.030000:0.000000
-lists5:0.040000:0.000000
-markup-inside-p:0.060000:0.000000
-more_comments:0.030000:0.000000
-multi-line-tags:0.040000:0.000000
-multi-test:0.100000:-12288.000000
-multiline-comments:0.060000:0.000000
-normalize:0.040000:0.000000
-numeric-entity:0.060000:0.000000
-php:0.070000:0.000000
-pre:0.050000:0.000000
-russian:0.220000:0.000000
-some-test:0.210000:0.000000
-span:0.110000:0.000000
-stronintags:0.100000:0.000000
-tabs-in-lists:0.140000:0.000000
-two-spaces:0.070000:0.000000
-uche:0.080000:0.000000
-underscores:0.100000:0.000000
-url_spaces:0.080000:0.000000
+email:0.030000:0.000000
+funky-list:0.060000:0.000000
+h1:0.040000:0.000000
+hash:0.040000:0.000000
+headers:0.060000:0.000000
+hline:0.020000:0.000000
+html:0.090000:0.000000
+image:0.040000:0.000000
+image-2:0.060000:0.000000
+image_in_links:0.060000:0.000000
+inside_html:0.040000:0.000000
+japanese:0.150000:0.000000
+lazy-block-quote:0.050000:0.000000
+lists:0.110000:0.000000
+lists2:0.040000:0.000000
+lists3:0.040000:0.000000
+lists4:0.050000:0.000000
+lists5:0.070000:0.000000
+markup-inside-p:0.080000:0.000000
+mismatched-tags:0.070000:0.000000
+more_comments:0.060000:0.000000
+multi-line-tags:0.080000:0.000000
+multi-paragraph-block-quote:0.070000:0.000000
+multi-test:0.150000:0.000000
+multiline-comments:0.090000:0.000000
+normalize:0.060000:0.000000
+numeric-entity:0.090000:0.000000
+php:0.080000:0.000000
+pre:0.080000:0.000000
+russian:0.200000:0.000000
+some-test:0.200000:0.000000
+span:0.140000:0.000000
+strong-with-underscores:0.090000:0.000000
+stronintags:0.160000:0.000000
+tabs-in-lists:0.170000:0.000000
+two-spaces:0.160000:0.000000
+uche:0.150000:0.000000
+underscores:0.120000:0.000000
+url_spaces:0.120000:0.000000
diff --git a/tests/safe_mode/inline-html-advanced.html b/tests/safe_mode/inline-html-advanced.html
new file mode 100644
index 0000000..bc59ab1
--- /dev/null
+++ b/tests/safe_mode/inline-html-advanced.html
@@ -0,0 +1,14 @@
+<p>Simple block on one line:
+</p>
+&lt;div&gt;foo&lt;/div&gt;
+
+<p>And nested without indentation:
+</p>
+&lt;div&gt;
+&lt;div&gt;
+&lt;div&gt;
+foo
+&lt;/div&gt;
+&lt;/div&gt;
+&lt;div&gt;bar&lt;/div&gt;
+&lt;/div&gt; \ No newline at end of file
diff --git a/tests/safe_mode/inline-html-advanced.txt b/tests/safe_mode/inline-html-advanced.txt
new file mode 100644
index 0000000..9d71ddc
--- /dev/null
+++ b/tests/safe_mode/inline-html-advanced.txt
@@ -0,0 +1,14 @@
+Simple block on one line:
+
+<div>foo</div>
+
+And nested without indentation:
+
+<div>
+<div>
+<div>
+foo
+</div>
+</div>
+<div>bar</div>
+</div>
diff --git a/tests/safe_mode/inline-html-comments.html b/tests/safe_mode/inline-html-comments.html
new file mode 100644
index 0000000..8deccba
--- /dev/null
+++ b/tests/safe_mode/inline-html-comments.html
@@ -0,0 +1,14 @@
+<p>Paragraph one.
+</p>
+&lt;!-- This is a simple comment --&gt;
+
+&lt;!--
+ This is another comment.
+--&gt;
+
+<p>Paragraph two.
+</p>
+&lt;!-- one comment block -- -- with two comments --&gt;
+
+<p>The end.
+</p> \ No newline at end of file
diff --git a/tests/safe_mode/inline-html-comments.txt b/tests/safe_mode/inline-html-comments.txt
new file mode 100644
index 0000000..41d830d
--- /dev/null
+++ b/tests/safe_mode/inline-html-comments.txt
@@ -0,0 +1,13 @@
+Paragraph one.
+
+<!-- This is a simple comment -->
+
+<!--
+ This is another comment.
+-->
+
+Paragraph two.
+
+<!-- one comment block -- -- with two comments -->
+
+The end.
diff --git a/tests/safe_mode/inline-html-simple.html b/tests/safe_mode/inline-html-simple.html
new file mode 100644
index 0000000..24d16ba
--- /dev/null
+++ b/tests/safe_mode/inline-html-simple.html
@@ -0,0 +1,64 @@
+<p>Here's a simple block:
+</p>
+&lt;div&gt;
+ foo
+&lt;/div&gt;
+
+<p>This should be a code block, though:
+</p>
+<pre><code>&lt;div&gt;
+ foo
+&lt;/div&gt;
+</code></pre><p>As should this:
+</p>
+<pre><code>&lt;div&gt;foo&lt;/div&gt;
+</code></pre><p>Now, nested:
+</p>
+&lt;div&gt;
+ &lt;div&gt;
+ &lt;div&gt;
+ foo
+ &lt;/div&gt;
+ &lt;/div&gt;
+&lt;/div&gt;
+
+<p>This should just be an HTML comment:
+</p>
+&lt;!-- Comment --&gt;
+
+<p>Multiline:
+</p>
+&lt;!--
+Blah
+Blah
+--&gt;
+
+<p>Code block:
+</p>
+<pre><code>&lt;!-- Comment --&gt;
+</code></pre><p>Just plain comment, with trailing spaces on the line:
+</p>
+&lt;!-- foo --&gt;
+
+<p>Code:
+</p>
+<pre><code>&lt;hr /&gt;
+</code></pre><p>Hr's:
+</p>
+&lt;hr&gt;
+
+&lt;hr/&gt;
+
+&lt;hr /&gt;
+
+&lt;hr&gt;
+
+&lt;hr/&gt;
+
+&lt;hr /&gt;
+
+&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;
+
+&lt;hr class=&quot;foo&quot; id=&quot;bar&quot;/&gt;
+
+&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; &gt; \ No newline at end of file
diff --git a/tests/safe_mode/inline-html-simple.txt b/tests/safe_mode/inline-html-simple.txt
new file mode 100644
index 0000000..14aa2dc
--- /dev/null
+++ b/tests/safe_mode/inline-html-simple.txt
@@ -0,0 +1,69 @@
+Here's a simple block:
+
+<div>
+ foo
+</div>
+
+This should be a code block, though:
+
+ <div>
+ foo
+ </div>
+
+As should this:
+
+ <div>foo</div>
+
+Now, nested:
+
+<div>
+ <div>
+ <div>
+ foo
+ </div>
+ </div>
+</div>
+
+This should just be an HTML comment:
+
+<!-- Comment -->
+
+Multiline:
+
+<!--
+Blah
+Blah
+-->
+
+Code block:
+
+ <!-- Comment -->
+
+Just plain comment, with trailing spaces on the line:
+
+<!-- foo -->
+
+Code:
+
+ <hr />
+
+Hr's:
+
+<hr>
+
+<hr/>
+
+<hr />
+
+<hr>
+
+<hr/>
+
+<hr />
+
+<hr class="foo" id="bar" />
+
+<hr class="foo" id="bar"/>
+
+<hr class="foo" id="bar" >
+
diff --git a/tests/safe_mode/script_tags.html b/tests/safe_mode/script_tags.html
new file mode 100644
index 0000000..cb2abfa
--- /dev/null
+++ b/tests/safe_mode/script_tags.html
@@ -0,0 +1,33 @@
+<p>This should be stripped/escaped in safe_mode.
+</p>
+&lt;script&gt;
+alert(&quot;Hello world!&quot;)
+&lt;/script&gt;
+
+<p>With blank lines.
+</p>
+&lt;script&gt;
+
+alert(&quot;Hello world!&quot;)
+
+&lt;/script&gt;
+
+<p>Now with some weirdness
+</p>
+<p><code>&lt;script &lt;!--
+alert("Hello world!")
+&lt;/script &lt;&gt;</code>`
+</p>
+<p>Try another way.
+</p>
+&lt;script &lt;!--
+alert(&quot;Hello world!&quot;)
+&lt;/script &lt;&gt;
+
+This time with blank lines.
+
+&lt;script &lt;!--
+
+alert(&quot;Hello world!&quot;)
+
+&lt;/script &lt;&gt; \ No newline at end of file
diff --git a/tests/safe_mode/script_tags.txt b/tests/safe_mode/script_tags.txt
new file mode 100644
index 0000000..55c60e9
--- /dev/null
+++ b/tests/safe_mode/script_tags.txt
@@ -0,0 +1,33 @@
+This should be stripped/escaped in safe_mode.
+
+<script>
+alert("Hello world!")
+</script>
+
+With blank lines.
+
+<script>
+
+alert("Hello world!")
+
+</script>
+
+Now with some weirdness
+
+``<script <!--
+alert("Hello world!")
+</script <>```
+
+Try another way.
+
+<script <!--
+alert("Hello world!")
+</script <>
+
+This time with blank lines.
+
+<script <!--
+
+alert("Hello world!")
+
+</script <>