From 2926ceba6a06a2f0f95452ae838a89247c493c93 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Fri, 13 Dec 2019 01:46:09 +0100 Subject: [ticket/16250] Add a service to check BBCodes safeness PHPBB3-16250 --- tests/functional/acp_bbcodes_test.php | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests/functional/acp_bbcodes_test.php') diff --git a/tests/functional/acp_bbcodes_test.php b/tests/functional/acp_bbcodes_test.php index 58681dfa07..cc6397fdfd 100644 --- a/tests/functional/acp_bbcodes_test.php +++ b/tests/functional/acp_bbcodes_test.php @@ -43,4 +43,44 @@ class phpbb_functional_acp_bbcodes_test extends phpbb_functional_test_case $this->assertContains('
c
', $html); $this->assertContains('
d
', $html); } + + /** + * @dataProvider get_bbcode_error_tests + */ + public function test_bbcode_error($match, $tpl, $error) + { + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', 'adm/index.php?i=acp_bbcodes&sid=' . $this->sid . '&mode=bbcodes&action=add'); + $form = $crawler->selectButton('Submit')->form([ + 'bbcode_match' => $match, + 'bbcode_tpl' => $tpl + ]); + $crawler = self::submit($form); + + $text = $crawler->filter('.errorbox')->text(); + $this->assertStringContainsString($error, $text); + } + + public function get_bbcode_error_tests() + { + return [ + [ + 'XXX', + '', + 'BBCode is constructed in an invalid form' + ], + [ + '[x]{TEXT}[/x]', + '{TEXT}', + 'unsafe' + ], + ]; + } } -- cgit v1.2.1