diff --git a/tests/Utils/Parser/Markdown/MarkdownTest.php b/tests/Utils/Parser/Markdown/MarkdownTest.php index 3cb3d218c..87fc643fb 100755 --- a/tests/Utils/Parser/Markdown/MarkdownTest.php +++ b/tests/Utils/Parser/Markdown/MarkdownTest.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace phpOMS\tests\Utils\Parser\Markdown; +include_once __DIR__ . '/../../../Autoloader.php'; + use phpOMS\System\File\Local\Directory; use phpOMS\Utils\Parser\Markdown\Markdown; @@ -42,4 +44,12 @@ final class MarkdownTest extends \PHPUnit\Framework\TestCase self::assertTrue(true); } + + public function testSafeMode() : void + { + $parser = new Markdown(); + $parser->setSafeMode(true); + + self::assertTrue(\file_get_contents(__DIR__ . '/manualdata/xss_bad_url.html') === ($parsed = $parser->text(\file_get_contents(__DIR__ . '/manualdata/xss_bad_url.md'))), $parsed); + } } diff --git a/tests/Utils/Parser/Markdown/data/abbreviation.html b/tests/Utils/Parser/Markdown/data/abbreviation.html new file mode 100644 index 000000000..9b3a45c40 --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/abbreviation.html @@ -0,0 +1,3 @@ +
The HTML specification +is maintained by the W3C. +The abbreviation ML is contained in the abbreviation HTML.
\ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/abbreviation.md b/tests/Utils/Parser/Markdown/data/abbreviation.md new file mode 100644 index 000000000..4ac8f8842 --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/abbreviation.md @@ -0,0 +1,7 @@ +The HTML specification +is maintained by the W3C. +The abbreviation ML is contained in the abbreviation HTML. + +*[HTML]: Hyper Text Markup Language +*[W3C]: World Wide Web Consortium +*[ML]: Markup Language \ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/atx_heading.html b/tests/Utils/Parser/Markdown/data/atx_heading.html index 751f8739f..d3ac53769 100755 --- a/tests/Utils/Parser/Markdown/data/atx_heading.html +++ b/tests/Utils/Parser/Markdown/data/atx_heading.html @@ -1,9 +1,9 @@ -####### not a heading
-#
\ No newline at end of file +-header
+header
paragraph
\ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/setext_header.html b/tests/Utils/Parser/Markdown/data/setext_header.html index 60aac0815..ca96add4d 100755 --- a/tests/Utils/Parser/Markdown/data/setext_header.html +++ b/tests/Utils/Parser/Markdown/data/setext_header.html @@ -1,5 +1,5 @@ -
- li
diff --git a/tests/Utils/Parser/Markdown/data/compound_footnote.html b/tests/Utils/Parser/Markdown/data/compound_footnote.html new file mode 100644 index 000000000..1a3848fd0 --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/compound_footnote.html @@ -0,0 +1,18 @@ + + \ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/compound_footnote.md b/tests/Utils/Parser/Markdown/data/compound_footnote.md new file mode 100644 index 000000000..f0a990488 --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/compound_footnote.md @@ -0,0 +1,13 @@ +footnote [^1] and another one [^2] + +[^1]: line 1 + line 2 + + > quote + + another paragraph + +[^2]: + paragraph + + another paragraph diff --git a/tests/Utils/Parser/Markdown/data/deeply_nested_list.html b/tests/Utils/Parser/Markdown/data/deeply_nested_list.html index d2c7e5acc..1c30acc00 100755 --- a/tests/Utils/Parser/Markdown/data/deeply_nested_list.html +++ b/tests/Utils/Parser/Markdown/data/deeply_nested_list.html @@ -1,12 +1,12 @@-
\ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/definition_list.html b/tests/Utils/Parser/Markdown/data/definition_list.html new file mode 100644 index 000000000..fb9b88d90 --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/definition_list.html @@ -0,0 +1,23 @@ +- li -
-
+- li -
++
- li
+
+- li
+
- li
- li
-- li
-- li
+
\ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/definition_list.md b/tests/Utils/Parser/Markdown/data/definition_list.md new file mode 100644 index 000000000..ec0ee03f3 --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/definition_list.md @@ -0,0 +1,20 @@ +Term 1 +: one +: two + extra line + +Term 2 + +: lazy +line + +: multiple + + paragraphs + +: nested + + code block + + > quote + > block \ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/footnote.html b/tests/Utils/Parser/Markdown/data/footnote.html new file mode 100644 index 000000000..d0ba76ce9 --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/footnote.html @@ -0,0 +1,20 @@ + + +- Term 1
+- one
+- two +extra line
+- Term 2
+- +
+lazy +line
+- +
+multiple
+paragraphs
+- +
+nested
++code block++quote +block
+second time 1
+ \ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/footnote.md b/tests/Utils/Parser/Markdown/data/footnote.md new file mode 100644 index 000000000..07d70103f --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/footnote.md @@ -0,0 +1,11 @@ +first [^1] second [^2]. + +[^1]: one +[^2]: two + +first [^a] second [^b]. + +[^a]: one +[^b]: two + +second time [^1] \ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/lazy_blockquote.html b/tests/Utils/Parser/Markdown/data/lazy_blockquote.html index 0a2a2aaf9..dea3dca32 100755 --- a/tests/Utils/Parser/Markdown/data/lazy_blockquote.html +++ b/tests/Utils/Parser/Markdown/data/lazy_blockquote.html @@ -1,6 +1,8 @@+quote the rest of it
+\ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/markdown_inside_markup.html b/tests/Utils/Parser/Markdown/data/markdown_inside_markup.html new file mode 100644 index 000000000..27da259f5 --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/markdown_inside_markup.html @@ -0,0 +1,25 @@ +another paragraph the rest of it
++markdown
+This is another paragraph. It contains inline markup.
++_no markdown_ ++
+++markdown
+++markdown
+
++_no markdown_ ++++markdown
+
++_no markdown_ +\ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/markdown_inside_markup.md b/tests/Utils/Parser/Markdown/data/markdown_inside_markup.md new file mode 100644 index 000000000..dbb85d66f --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/markdown_inside_markup.md @@ -0,0 +1,32 @@ ++_markdown_ + +This is another paragraph. It contains inline markup. ++ +--- + ++_no markdown_ +++_markdown_ ++ +--- + ++_markdown_ +++_no markdown_ ++ +--- + ++_markdown_ +++_no markdown_ +\ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/paragraph_list.html b/tests/Utils/Parser/Markdown/data/paragraph_list.html index ced1c43ee..00a612c13 100755 --- a/tests/Utils/Parser/Markdown/data/paragraph_list.html +++ b/tests/Utils/Parser/Markdown/data/paragraph_list.html @@ -8,5 +8,7 @@- -
li
- li
+- +
li
+h1
-h2
-single character
+h1
+h2
+single character
not a header
\ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/sparse_list.html b/tests/Utils/Parser/Markdown/data/sparse_list.html index 452b2b86d..9803d27cd 100755 --- a/tests/Utils/Parser/Markdown/data/sparse_list.html +++ b/tests/Utils/Parser/Markdown/data/sparse_list.html @@ -2,7 +2,9 @@- li
li ++ li
+
diff --git a/tests/Utils/Parser/Markdown/data/special_attributes.html b/tests/Utils/Parser/Markdown/data/special_attributes.html new file mode 100644 index 000000000..42eae7871 --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/special_attributes.html @@ -0,0 +1,6 @@ +
Header 1
+Header 2
+The Site
+The Site
+ +\ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/special_attributes.md b/tests/Utils/Parser/Markdown/data/special_attributes.md new file mode 100644 index 000000000..01f29fc97 --- /dev/null +++ b/tests/Utils/Parser/Markdown/data/special_attributes.md @@ -0,0 +1,12 @@ +Header 1 {#header1} +======== + +## Header 2 ## {#header2} + +## The Site ## {.main} + +## The Site ## {.main .shine #the-site} + +[link](http://parsedown.org) {.primary #link .upper-case} + + {#logo .big} \ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/unordered_list.html b/tests/Utils/Parser/Markdown/data/unordered_list.html index cd95567b7..a52e06b3a 100755 --- a/tests/Utils/Parser/Markdown/data/unordered_list.html +++ b/tests/Utils/Parser/Markdown/data/unordered_list.html @@ -5,6 +5,10 @@
mixed markers:
+
- li
++
- li
+\ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/xss_bad_url.html b/tests/Utils/Parser/Markdown/manualdata/xss_bad_url.html old mode 100755 new mode 100644 similarity index 100% rename from tests/Utils/Parser/Markdown/data/xss_bad_url.html rename to tests/Utils/Parser/Markdown/manualdata/xss_bad_url.html diff --git a/tests/Utils/Parser/Markdown/data/xss_bad_url.md b/tests/Utils/Parser/Markdown/manualdata/xss_bad_url.md old mode 100755 new mode 100644 similarity index 100% rename from tests/Utils/Parser/Markdown/data/xss_bad_url.md rename to tests/Utils/Parser/Markdown/manualdata/xss_bad_url.md
- li