diff options
| author | Tristan Darricau <github@nicofuma.fr> | 2016-10-03 20:05:49 +0200 |
|---|---|---|
| committer | Tristan Darricau <github@nicofuma.fr> | 2016-10-03 20:05:49 +0200 |
| commit | 1ad64f89b817a42722b522f4a763424eea3b5a5f (patch) | |
| tree | d4210f8a202f386ef4f3bb47b456ae5300943b64 | |
| parent | 85e4566223487899f3a2789983cb50e68296a982 (diff) | |
| parent | bf8ee698f9275b8baf46ebe74de79cd54a30756b (diff) | |
| download | forums-1ad64f89b817a42722b522f4a763424eea3b5a5f.tar forums-1ad64f89b817a42722b522f4a763424eea3b5a5f.tar.gz forums-1ad64f89b817a42722b522f4a763424eea3b5a5f.tar.bz2 forums-1ad64f89b817a42722b522f4a763424eea3b5a5f.tar.xz forums-1ad64f89b817a42722b522f4a763424eea3b5a5f.zip | |
Merge pull request #4471 from dsinn/ticket/14802
[ticket/14802] Empty/blank lines should not be additional poll options
* dsinn/ticket/14802:
[ticket/14802] Add test for empty/blank lines in poll options
[ticket/14802] Empty/blank lines should not be additional poll options
| -rw-r--r-- | phpBB/includes/message_parser.php | 2 | ||||
| -rw-r--r-- | tests/functional/posting_test.php | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index e63f6b822b..16b65fb83e 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -1822,7 +1822,7 @@ class parse_message extends bbcode_firstpass $this->message = $poll['poll_title']; $this->bbcode_bitfield = $bbcode_bitfield; - $poll['poll_options'] = explode("\n", trim($poll['poll_option_text'])); + $poll['poll_options'] = preg_split('/\s*?\n\s*/', trim($poll['poll_option_text'])); $poll['poll_options_size'] = sizeof($poll['poll_options']); if (!$poll['poll_title'] && $poll['poll_options_size']) diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 33632a01e1..914233240e 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -130,6 +130,22 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case } } + public function test_post_poll() + { + $this->login(); + + $post = $this->create_topic( + 2, + '[ticket/14802] Test Poll Option Spacing', + 'Empty/blank lines should not be additional poll options.', + array('poll_title' => 'Poll Title', 'poll_option_text' => "\n A \nB\n\nC \n D\nE\n\n \n") + ); + + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + $this->assertEquals('Poll Title', $crawler->filter('.poll-title')->text()); + $this->assertEquals(5, $crawler->filter('*[data-poll-option-id]')->count()); + } + protected function set_quote_depth($depth) { $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post'); |
