From b69c9b708ccb45fbaa3e8093878dc0b6b2ba3458 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 21 Sep 2023 22:22:09 +0000 Subject: [PATCH] update markdown --- tests/Utils/Parser/Markdown/MarkdownTest.php | 10 ++++++ .../Parser/Markdown/data/abbreviation.html | 3 ++ .../Parser/Markdown/data/abbreviation.md | 7 ++++ .../Parser/Markdown/data/atx_heading.html | 16 +++++----- .../Markdown/data/compound_blockquote.html | 2 +- .../Markdown/data/compound_footnote.html | 18 +++++++++++ .../Parser/Markdown/data/compound_footnote.md | 13 ++++++++ .../Markdown/data/deeply_nested_list.html | 12 +++---- .../Parser/Markdown/data/definition_list.html | 23 +++++++++++++ .../Parser/Markdown/data/definition_list.md | 20 ++++++++++++ .../Utils/Parser/Markdown/data/footnote.html | 20 ++++++++++++ tests/Utils/Parser/Markdown/data/footnote.md | 11 +++++++ .../Parser/Markdown/data/lazy_blockquote.html | 2 ++ .../Markdown/data/markdown_inside_markup.html | 25 +++++++++++++++ .../Markdown/data/markdown_inside_markup.md | 32 +++++++++++++++++++ .../Parser/Markdown/data/paragraph_list.html | 4 ++- .../Parser/Markdown/data/setext_header.html | 6 ++-- .../Parser/Markdown/data/sparse_list.html | 4 ++- .../Markdown/data/special_attributes.html | 6 ++++ .../Markdown/data/special_attributes.md | 12 +++++++ .../Parser/Markdown/data/unordered_list.html | 4 +++ .../{data => manualdata}/xss_bad_url.html | 0 .../{data => manualdata}/xss_bad_url.md | 0 23 files changed, 230 insertions(+), 20 deletions(-) create mode 100644 tests/Utils/Parser/Markdown/data/abbreviation.html create mode 100644 tests/Utils/Parser/Markdown/data/abbreviation.md create mode 100644 tests/Utils/Parser/Markdown/data/compound_footnote.html create mode 100644 tests/Utils/Parser/Markdown/data/compound_footnote.md create mode 100644 tests/Utils/Parser/Markdown/data/definition_list.html create mode 100644 tests/Utils/Parser/Markdown/data/definition_list.md create mode 100644 tests/Utils/Parser/Markdown/data/footnote.html create mode 100644 tests/Utils/Parser/Markdown/data/footnote.md create mode 100644 tests/Utils/Parser/Markdown/data/markdown_inside_markup.html create mode 100644 tests/Utils/Parser/Markdown/data/markdown_inside_markup.md create mode 100644 tests/Utils/Parser/Markdown/data/special_attributes.html create mode 100644 tests/Utils/Parser/Markdown/data/special_attributes.md rename tests/Utils/Parser/Markdown/{data => manualdata}/xss_bad_url.html (100%) mode change 100755 => 100644 rename tests/Utils/Parser/Markdown/{data => manualdata}/xss_bad_url.md (100%) mode change 100755 => 100644 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

    +