From 9a03b3aab6033b52492296730c30849f96f430bf Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 24 Jan 2015 12:49:58 +0100 Subject: [PATCH] [ticket/13522] Remove empty answers from possible answers in Q&A PHPBB3-13522 --- phpBB/phpbb/captcha/plugins/qa.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php index a7ba994cc3..13ff3d7f91 100644 --- a/phpBB/phpbb/captcha/plugins/qa.php +++ b/phpBB/phpbb/captcha/plugins/qa.php @@ -827,13 +827,22 @@ class qa function acp_get_question_input() { $answers = utf8_normalize_nfc(request_var('answers', '', true)); + + // Convert answers into array and filter if answers are set + if (strlen($answers)) + { + $answers = array_filter(explode("\n", $answers), function ($value) { + return trim($value) !== ''; + }); + } + + $question = array( 'question_text' => request_var('question_text', '', true), 'strict' => request_var('strict', false), 'lang_iso' => request_var('lang_iso', ''), - 'answers' => (strlen($answers)) ? explode("\n", $answers) : '', + 'answers' => $answers, ); - return $question; }