Skip to content

Commit 7bb4e88

Browse files
committed
Merge branch '3.1.x' into 3.2.x
* 3.1.x: [ticket/14802] Add test for empty/blank lines in poll options [ticket/14802] Empty/blank lines should not be additional poll options
2 parents b28fe0a + 1ad64f8 commit 7bb4e88

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

phpBB/includes/message_parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,7 @@ function parse_poll(&$poll)
18601860
// Parse Poll Option text
18611861
$tmp_message = $this->message;
18621862

1863-
$poll['poll_options'] = explode("\n", trim($poll['poll_option_text']));
1863+
$poll['poll_options'] = preg_split('/\s*?\n\s*/', trim($poll['poll_option_text']));
18641864
$poll['poll_options_size'] = sizeof($poll['poll_options']);
18651865

18661866
foreach ($poll['poll_options'] as &$poll_option)

tests/functional/posting_test.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,22 @@ public function test_quote_depth_submit()
159159
}
160160
}
161161

162+
public function test_post_poll()
163+
{
164+
$this->login();
165+
166+
$post = $this->create_topic(
167+
2,
168+
'[ticket/14802] Test Poll Option Spacing',
169+
'Empty/blank lines should not be additional poll options.',
170+
array('poll_title' => 'Poll Title', 'poll_option_text' => "\n A \nB\n\nC \n D\nE\n\n \n")
171+
);
172+
173+
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
174+
$this->assertEquals('Poll Title', $crawler->filter('.poll-title')->text());
175+
$this->assertEquals(5, $crawler->filter('*[data-poll-option-id]')->count());
176+
}
177+
162178
protected function set_quote_depth($depth)
163179
{
164180
$crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');

0 commit comments

Comments
 (0)