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 @@ -

h1

-

h2

-

h3

-

h4

-
h5
-
h6
+

h1

+

h2

+

h3

+

h4

+
h5
+
h6

####### not a heading

-

closed h1

-

#

\ No newline at end of file +

closed h1

+

\ No newline at end of file diff --git a/tests/Utils/Parser/Markdown/data/compound_blockquote.html b/tests/Utils/Parser/Markdown/data/compound_blockquote.html index 37afb57a4..5aeec2596 100755 --- a/tests/Utils/Parser/Markdown/data/compound_blockquote.html +++ b/tests/Utils/Parser/Markdown/data/compound_blockquote.html @@ -1,5 +1,5 @@
-

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 @@ -

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

    +