aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2015-03-14 20:39:46 -0400
committerWaylan Limberg <waylan.limberg@icloud.com>2018-01-11 19:04:49 -0500
commit7f63b20b819b83afef0ddadc2e210ddce32a2be3 (patch)
treec92e6bbd942e65588466c5800a32545fc1d57948 /tests
parent6366e5ae8f0ae19c033a2c24c217001c1512292b (diff)
downloadmarkdown-7f63b20b819b83afef0ddadc2e210ddce32a2be3.tar.gz
markdown-7f63b20b819b83afef0ddadc2e210ddce32a2be3.tar.bz2
markdown-7f63b20b819b83afef0ddadc2e210ddce32a2be3.zip
Removed deprecated safe_mode.
Diffstat (limited to 'tests')
-rw-r--r--tests/safe_mode/html_then_blockquote.html6
-rw-r--r--tests/safe_mode/html_then_blockquote.txt6
-rw-r--r--tests/safe_mode/inline-html-advanced.html11
-rw-r--r--tests/safe_mode/inline-html-advanced.txt14
-rw-r--r--tests/safe_mode/inline-html-comments.html8
-rw-r--r--tests/safe_mode/inline-html-comments.txt13
-rw-r--r--tests/safe_mode/inline-html-simple.html46
-rw-r--r--tests/safe_mode/inline-html-simple.txt70
-rw-r--r--tests/safe_mode/link-targets.html2
-rw-r--r--tests/safe_mode/link-targets.txt3
-rw-r--r--tests/safe_mode/remove.html35
-rw-r--r--tests/safe_mode/remove.txt70
-rw-r--r--tests/safe_mode/replace.html35
-rw-r--r--tests/safe_mode/replace.txt70
-rw-r--r--tests/safe_mode/script_tags.html20
-rw-r--r--tests/safe_mode/script_tags.txt33
-rw-r--r--tests/safe_mode/unsafe_urls.html20
-rw-r--r--tests/safe_mode/unsafe_urls.txt27
-rw-r--r--tests/test_apis.py36
-rw-r--r--tests/test_legacy.py9
20 files changed, 2 insertions, 532 deletions
diff --git a/tests/safe_mode/html_then_blockquote.html b/tests/safe_mode/html_then_blockquote.html
deleted file mode 100644
index 62d24e4..0000000
--- a/tests/safe_mode/html_then_blockquote.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<p>to:</p>
-<p>&lt;td /&gt;&lt;td style="text-align: center; white-space: nowrap;"&gt;&lt;br /&gt;</p>
-<blockquote>
-<p>3) You don't need to alter all localization files.
- Adding the new labels to the en_US files will do it.</p>
-</blockquote> \ No newline at end of file
diff --git a/tests/safe_mode/html_then_blockquote.txt b/tests/safe_mode/html_then_blockquote.txt
deleted file mode 100644
index 544df67..0000000
--- a/tests/safe_mode/html_then_blockquote.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-to:
-
-<td /><td style="text-align: center; white-space: nowrap;"><br />
-
-> 3) You don't need to alter all localization files.
-> Adding the new labels to the en_US files will do it.
diff --git a/tests/safe_mode/inline-html-advanced.html b/tests/safe_mode/inline-html-advanced.html
deleted file mode 100644
index e9dd2ec..0000000
--- a/tests/safe_mode/inline-html-advanced.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<p>Simple block on one line:</p>
-<p>&lt;div&gt;foo&lt;/div&gt;</p>
-<p>And nested without indentation:</p>
-<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;</p> \ No newline at end of file
diff --git a/tests/safe_mode/inline-html-advanced.txt b/tests/safe_mode/inline-html-advanced.txt
deleted file mode 100644
index 9d71ddc..0000000
--- a/tests/safe_mode/inline-html-advanced.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-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
deleted file mode 100644
index 0f1e417..0000000
--- a/tests/safe_mode/inline-html-comments.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<p>Paragraph one.</p>
-<p>&lt;!-- This is a simple comment --&gt;</p>
-<p>&lt;!--
- This is another comment.
---&gt;</p>
-<p>Paragraph two.</p>
-<p>&lt;!-- one comment block -- -- with two comments --&gt;</p>
-<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
deleted file mode 100644
index 41d830d..0000000
--- a/tests/safe_mode/inline-html-comments.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-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
deleted file mode 100644
index 1e5df17..0000000
--- a/tests/safe_mode/inline-html-simple.html
+++ /dev/null
@@ -1,46 +0,0 @@
-<p>Here's a simple block:</p>
-<p>&lt;div&gt;
- foo
-&lt;/div&gt;</p>
-<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>
-<p>&lt;div&gt;
- &lt;div&gt;
- &lt;div&gt;
- foo
- &lt;/div&gt;
- &lt;/div&gt;
-&lt;/div&gt;</p>
-<p>This should just be an HTML comment:</p>
-<p>&lt;!-- Comment --&gt;</p>
-<p>Multiline:</p>
-<p>&lt;!--
-Blah
-Blah
---&gt;</p>
-<p>Code block:</p>
-<pre><code>&lt;!-- Comment --&gt;
-</code></pre>
-<p>Just plain comment, with trailing spaces on the line:</p>
-<p>&lt;!-- foo --&gt; </p>
-<p>Code:</p>
-<pre><code>&lt;hr /&gt;
-</code></pre>
-<p>Hr's:</p>
-<p>&lt;hr&gt;</p>
-<p>&lt;hr/&gt;</p>
-<p>&lt;hr /&gt;</p>
-<p>&lt;hr&gt; </p>
-<p>&lt;hr/&gt; </p>
-<p>&lt;hr /&gt; </p>
-<p>&lt;hr class="foo" id="bar" /&gt;</p>
-<p>&lt;hr class="foo" id="bar"/&gt;</p>
-<p>&lt;hr class="foo" id="bar" &gt;</p>
-<p>&lt;some <a href="http://example.com">weird</a> stuff&gt;</p> \ No newline at end of file
diff --git a/tests/safe_mode/inline-html-simple.txt b/tests/safe_mode/inline-html-simple.txt
deleted file mode 100644
index 7210750..0000000
--- a/tests/safe_mode/inline-html-simple.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-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" >
-
-<some [weird](http://example.com) stuff>
diff --git a/tests/safe_mode/link-targets.html b/tests/safe_mode/link-targets.html
deleted file mode 100644
index 768ae5b..0000000
--- a/tests/safe_mode/link-targets.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<p><a href="">XSS</a>
-See http://security.stackexchange.com/q/30330/1261 for details.</p> \ No newline at end of file
diff --git a/tests/safe_mode/link-targets.txt b/tests/safe_mode/link-targets.txt
deleted file mode 100644
index 10eebda..0000000
--- a/tests/safe_mode/link-targets.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-[XSS](javascript://%0Aalert%28'XSS'%29;)
-See http://security.stackexchange.com/q/30330/1261 for details.
-
diff --git a/tests/safe_mode/remove.html b/tests/safe_mode/remove.html
deleted file mode 100644
index d86b2b4..0000000
--- a/tests/safe_mode/remove.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<p>Here's a simple block:</p>
-<p></p>
-<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>
-<p></p>
-<p>This should just be an HTML comment:</p>
-<p></p>
-<p>Multiline:</p>
-<p></p>
-<p>Code block:</p>
-<pre><code>&lt;!-- Comment --&gt;
-</code></pre>
-<p>Just plain comment, with trailing spaces on the line:</p>
-<p></p>
-<p>Code:</p>
-<pre><code>&lt;hr /&gt;
-</code></pre>
-<p>Hr's:</p>
-<p></p>
-<p></p>
-<p></p>
-<p></p>
-<p></p>
-<p></p>
-<p></p>
-<p></p>
-<p></p>
-<p></p> \ No newline at end of file
diff --git a/tests/safe_mode/remove.txt b/tests/safe_mode/remove.txt
deleted file mode 100644
index 7210750..0000000
--- a/tests/safe_mode/remove.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-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" >
-
-<some [weird](http://example.com) stuff>
diff --git a/tests/safe_mode/replace.html b/tests/safe_mode/replace.html
deleted file mode 100644
index cb6bfb5..0000000
--- a/tests/safe_mode/replace.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<p>Here's a simple block:</p>
-<p>[HTML_REMOVED]</p>
-<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>
-<p>[HTML_REMOVED]</p>
-<p>This should just be an HTML comment:</p>
-<p>[HTML_REMOVED]</p>
-<p>Multiline:</p>
-<p>[HTML_REMOVED]</p>
-<p>Code block:</p>
-<pre><code>&lt;!-- Comment --&gt;
-</code></pre>
-<p>Just plain comment, with trailing spaces on the line:</p>
-<p>[HTML_REMOVED]</p>
-<p>Code:</p>
-<pre><code>&lt;hr /&gt;
-</code></pre>
-<p>Hr's:</p>
-<p>[HTML_REMOVED]</p>
-<p>[HTML_REMOVED]</p>
-<p>[HTML_REMOVED]</p>
-<p>[HTML_REMOVED]</p>
-<p>[HTML_REMOVED]</p>
-<p>[HTML_REMOVED]</p>
-<p>[HTML_REMOVED]</p>
-<p>[HTML_REMOVED]</p>
-<p>[HTML_REMOVED]</p>
-<p>[HTML_REMOVED]</p> \ No newline at end of file
diff --git a/tests/safe_mode/replace.txt b/tests/safe_mode/replace.txt
deleted file mode 100644
index 7210750..0000000
--- a/tests/safe_mode/replace.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-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" >
-
-<some [weird](http://example.com) stuff>
diff --git a/tests/safe_mode/script_tags.html b/tests/safe_mode/script_tags.html
deleted file mode 100644
index 6c1501b..0000000
--- a/tests/safe_mode/script_tags.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<p>This should be stripped/escaped in safe_mode.</p>
-<p>&lt;script&gt;
-alert("Hello world!")
-&lt;/script&gt;</p>
-<p>With blank lines.</p>
-<p>&lt;script&gt;</p>
-<p>alert("Hello world!")</p>
-<p>&lt;/script&gt;</p>
-<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>
-<p>&lt;script &lt;!--
-alert("Hello world!")
-&lt;/script &lt;&gt;</p>
-<p>This time with blank lines.</p>
-<p>&lt;script &lt;!--</p>
-<p>alert("Hello world!")</p>
-<p>&lt;/script &lt;&gt;</p> \ No newline at end of file
diff --git a/tests/safe_mode/script_tags.txt b/tests/safe_mode/script_tags.txt
deleted file mode 100644
index 44041c2..0000000
--- a/tests/safe_mode/script_tags.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-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 <>
diff --git a/tests/safe_mode/unsafe_urls.html b/tests/safe_mode/unsafe_urls.html
deleted file mode 100644
index e617f35..0000000
--- a/tests/safe_mode/unsafe_urls.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<p>These links should be unsafe and not allowed in safe_mode</p>
-<p><a href="">link</a>
-<a href="">link</a>
-<a href="">link</a>
-<a href="">link</a>
-<a href="">link</a>
-<a href="">link</a>
-<a href="">link</a>
-<a href="">link</a>
-<a href="">link</a>
-<a href="">link</a>
-<a href="">link</a></p>
-<p><img alt="img" src="" />
-<a href="">ref</a>
-<img alt="imgref" src="" /></p>
-<p>These should work regardless:</p>
-<p><a href="relative/url.html">relative</a>
-<a href="mailto:foo@bar.com">email</a>
-<a href="news:some.news.group.com">news scheme</a>
-<a href="http://example.com">http link</a></p> \ No newline at end of file
diff --git a/tests/safe_mode/unsafe_urls.txt b/tests/safe_mode/unsafe_urls.txt
deleted file mode 100644
index 7bfd81d..0000000
--- a/tests/safe_mode/unsafe_urls.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-These links should be unsafe and not allowed in safe_mode
-
-[link](javascript:alert%28'Hello%20world!'%29)
-[link](vbscript:msgbox%28%22Hello%20world!%22%29)
-[link](livescript:alert%28'Hello%20world!'%29)
-[link](mocha:[code])
-[link](jAvAsCrIpT:alert%28'Hello%20world!'%29)
-[link](ja&#32;vas&#32;cr&#32;ipt:alert%28'Hello%20world!'%29)
-[link](ja&#00032;vas&#32;cr&#32;ipt:alert%28'Hello%20world!'%29)
-[link](ja&#x00020;vas&#32;cr&#32;ipt:alert%28'Hello%20world!'%29)
-[link](ja%09&#x20;%0Avas&#32;cr&#x0a;ipt:alert%28'Hello%20world!'%29)
-[link](ja%20vas%20cr%20ipt:alert%28'Hello%20world!'%29)
-[link](live%20script:alert%28'Hello%20world!'%29)
-
-![img](javascript:alert%29'XSS'%29)
-[ref][]
-![imgref][]
-
-[ref]: javascript:alert%29'XSS'%29
-[imgref]: javascript:alert%29'XSS'%29
-
-These should work regardless:
-
-[relative](relative/url.html)
-[email](mailto:foo@bar.com)
-[news scheme](news:some.news.group.com)
-[http link](http://example.com)
diff --git a/tests/test_apis.py b/tests/test_apis.py
index d128948..6a1829b 100644
--- a/tests/test_apis.py
+++ b/tests/test_apis.py
@@ -133,7 +133,7 @@ class TestHtmlStash(unittest.TestCase):
""" Test HtmlStash.store. """
self.assertEqual(self.placeholder, self.stash.get_placeholder(0))
self.assertEqual(self.stash.html_counter, 1)
- self.assertEqual(self.stash.rawHtmlBlocks, [('foo', False)])
+ self.assertEqual(self.stash.rawHtmlBlocks, ['foo'])
def testStoreMore(self):
""" Test HtmlStash.store with additional blocks. """
@@ -142,15 +142,7 @@ class TestHtmlStash(unittest.TestCase):
self.assertEqual(self.stash.html_counter, 2)
self.assertEqual(
self.stash.rawHtmlBlocks,
- [('foo', False), ('bar', False)]
- )
-
- def testSafeStore(self):
- """ Test HtmlStash.store with 'safe' html. """
- self.stash.store('bar', True)
- self.assertEqual(
- self.stash.rawHtmlBlocks,
- [('foo', False), ('bar', True)]
+ ['foo', 'bar']
)
def testReset(self):
@@ -159,25 +151,6 @@ class TestHtmlStash(unittest.TestCase):
self.assertEqual(self.stash.html_counter, 0)
self.assertEqual(self.stash.rawHtmlBlocks, [])
- def testUnsafeHtmlInSafeMode(self):
- """ Test that unsafe HTML gets escaped in safe_mode. """
- output = markdown.markdown('foo', extensions=[self.build_extension()], safe_mode='escape')
- self.assertEqual(output, '<p>&lt;script&gt;print(&quot;evil&quot;)&lt;/script&gt;</p>')
-
- def build_extension(self):
- """ Build an extention that addes unsafe html to Stash in same_mode. """
- class Unsafe(markdown.treeprocessors.Treeprocessor):
- def run(self, root):
- el = root.find('p')
- el.text = self.markdown.htmlStash.store('<script>print("evil")</script>', safe=False)
- return root
-
- class StoreUnsafeHtml(markdown.extensions.Extension):
- def extendMarkdown(self, md, md_globals):
- md.treeprocessors.add('unsafe', Unsafe(md), '_end')
-
- return StoreUnsafeHtml()
-
class TestOrderedDict(unittest.TestCase):
""" Test OrderedDict storage class. """
@@ -655,11 +628,6 @@ class TestCliOptionParsing(unittest.TestCase):
self.default_options['encoding'] = 'utf-8'
self.assertEqual(options, self.default_options)
- def testSafeModeOption(self):
- options, logging_level = parse_options(['-s', 'escape'])
- self.default_options['safe_mode'] = 'escape'
- self.assertEqual(options, self.default_options)
-
def testOutputFormatOption(self):
options, logging_level = parse_options(['-o', 'html5'])
self.default_options['output_format'] = 'html5'
diff --git a/tests/test_legacy.py b/tests/test_legacy.py
index 17c4282..ddc54bb 100644
--- a/tests/test_legacy.py
+++ b/tests/test_legacy.py
@@ -31,15 +31,6 @@ class TestOptions(LegacyTestCase):
no_smart_emphasis = Kwargs(smart_emphasis=False)
-class TestSafeMode(LegacyTestCase):
- location = os.path.join(parent_test_dir, 'safe_mode')
- default_kwargs = Kwargs(safe_mode='escape')
-
- remove = Kwargs(safe_mode='remove')
-
- replace = Kwargs(safe_mode='replace')
-
-
class TestPhp(LegacyTestCase):
"""
Notes on "excluded" tests: