From 56df3fd8cafde10b230c925c7eb455003ae76382 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 20 Jul 2013 22:02:51 +0200 Subject: [ticket/11720] Do not call $captcha->validate if $captcha is not set PHPBB3-11566 changed big parts of code. Unfortunately, a call to $captcha->validate was added that is being called even if $captcha hasn't been initialized. This change will fix this issue. PHPBB3-11720 --- phpBB/report.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phpBB/report.php b/phpBB/report.php index c92ecdfdcc..c909b4fcf3 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -146,10 +146,13 @@ $s_hidden_fields = ''; // Submit report? if ($submit && $reason_id) { - $visual_confirmation_response = $captcha->validate(); - if ($visual_confirmation_response) + if (isset($captcha)) { - $error[] = $visual_confirmation_response; + $visual_confirmation_response = $captcha->validate(); + if ($visual_confirmation_response) + { + $error[] = $visual_confirmation_response; + } } $sql = 'SELECT * -- cgit v1.2.1 From 865bf0db3d5ca3f8bbadd009ce0a5e8324de49c1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 20 Jul 2013 22:35:45 +0200 Subject: [ticket/11720] Add functional test for submitting report as user The already existing functional tests were not ran as the filename was missing the appended "_test". PHPBB3-11720 --- tests/functional/report_post_captcha.php | 61 ------------------------- tests/functional/report_post_captcha_test.php | 66 +++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 61 deletions(-) delete mode 100644 tests/functional/report_post_captcha.php create mode 100644 tests/functional/report_post_captcha_test.php diff --git a/tests/functional/report_post_captcha.php b/tests/functional/report_post_captcha.php deleted file mode 100644 index af713775c5..0000000000 --- a/tests/functional/report_post_captcha.php +++ /dev/null @@ -1,61 +0,0 @@ -login(); - $crawler = self::request('GET', 'report.php?f=2&p=1'); - $this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); - } - - public function test_guest_report_post() - { - $crawler = self::request('GET', 'report.php?f=2&p=1'); - $this->add_lang('mcp'); - $this->assertContains($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text()); - - $this->set_reporting_guest(1); - $crawler = self::request('GET', 'report.php?f=2&p=1'); - $this->assertContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); - $this->set_reporting_guest(-1); - } - - protected function set_reporting_guest($report_post_allowed) - { - $this->login(); - $this->admin_login(); - - $crawler = self::request('GET', 'adm/index.php?i=permissions&icat=12&mode=setting_group_local&sid=' . $this->sid); - $form = $crawler->selectButton('Submit')->form(); - $values = $form->getValues(); - $values["group_id[0]"] = 1; - $form->setValues($values); - $crawler = self::submit($form); - - $form = $crawler->selectButton('Submit')->form(); - $values = $form->getValues(); - $values["forum_id"] = 2; - $form->setValues($values); - $crawler = self::submit($form); - - $this->add_lang('acp/permissions'); - $form = $crawler->selectButton($this->lang('APPLY_ALL_PERMISSIONS'))->form(); - $values = $form->getValues(); - $values["setting[1][2][f_report]"] = $report_post_allowed; - $form->setValues($values); - $crawler = self::submit($form); - - $crawler = self::request('GET', 'ucp.php?mode=logout&sid=' . $this->sid); - } -} diff --git a/tests/functional/report_post_captcha_test.php b/tests/functional/report_post_captcha_test.php new file mode 100644 index 0000000000..8283465041 --- /dev/null +++ b/tests/functional/report_post_captcha_test.php @@ -0,0 +1,66 @@ +add_lang('mcp'); + $this->assertContains($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text()); + + $this->set_reporting_guest(1); + $crawler = self::request('GET', 'report.php?f=2&p=1'); + $this->assertContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); + $this->set_reporting_guest(-1); + } + + public function test_user_report_post() + { + $this->login(); + $crawler = self::request('GET', 'report.php?f=2&p=1'); + $this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form); + $this->assertContains($this->lang('POST_REPORTED_SUCCESS'), $crawler->text()); + } + + protected function set_reporting_guest($report_post_allowed) + { + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', 'adm/index.php?i=permissions&icat=12&mode=setting_group_local&sid=' . $this->sid); + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + $values["group_id[0]"] = 1; + $form->setValues($values); + $crawler = self::submit($form); + + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + $values["forum_id"] = 2; + $form->setValues($values); + $crawler = self::submit($form); + + $this->add_lang('acp/permissions'); + $form = $crawler->selectButton($this->lang('APPLY_ALL_PERMISSIONS'))->form(); + $values = $form->getValues(); + $values["setting[1][2][f_report]"] = $report_post_allowed; + $form->setValues($values); + $crawler = self::submit($form); + + $crawler = self::request('GET', 'ucp.php?mode=logout&sid=' . $this->sid); + } +} -- cgit v1.2.1