From 288def143cb8f594fd5c58d6a6dab07263a6c60e Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Tue, 7 Nov 2017 10:34:11 +0100 Subject: [ticket/15442] Allow unsafe HTML in bbcode.html PHPBB3-15442 --- tests/text_formatter/s9e/factory_test.php | 16 +++++++++ .../fixtures/styles/unsafe/template/bbcode.html | 40 ++++++++++++++++++++++ .../s9e/fixtures/unsafe_default_bbcodes.xml | 24 +++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html create mode 100644 tests/text_formatter/s9e/fixtures/unsafe_default_bbcodes.xml (limited to 'tests/text_formatter') diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index fd9b4e4c09..d35330a975 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -247,6 +247,22 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case $this->assertSame($expected, $renderer->render($parser->parse($original))); } + /** + * @testdox Accepts unsafe default BBCodes + */ + public function test_unsafe_default_bbcodes() + { + $fixture = __DIR__ . '/fixtures/unsafe_default_bbcodes.xml'; + $style_dir = __DIR__ . '/fixtures/styles/'; + $container = $this->get_test_case_helpers()->set_s9e_services(null, $fixture, $style_dir); + $parser = $container->get('text_formatter.parser'); + $renderer = $container->get('text_formatter.renderer'); + + $original = '[b]alert(1)[/b]'; + $expected = ''; + $this->assertSame($expected, $renderer->render($parser->parse($original))); + } + /** * @testdox get_configurator() triggers events before and after configuration */ diff --git a/tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html new file mode 100644 index 0000000000..f3932f9b78 --- /dev/null +++ b/tests/text_formatter/s9e/fixtures/styles/unsafe/template/bbcode.html @@ -0,0 +1,40 @@ +