From 8a02db317ef3c2d3c4e3dcfc5f8b85397f7ebb4a Mon Sep 17 00:00:00 2001 From: s9e Date: Sat, 3 Aug 2013 12:20:52 +0200 Subject: [PATCH 1/3] [ticket/11762] Use the === operator to distinguish "0" from "" PHPBB3-11762 --- phpBB/includes/functions_content.php | 4 +-- .../generate_text_for_display.php | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/text_processing/generate_text_for_display.php diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index b7650ecd6a..6213d2fd24 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -413,7 +413,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags) { static $bbcode; - if (!$text) + if ($text === '') { return ''; } @@ -459,7 +459,7 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb $uid = $bitfield = ''; $flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0); - if (!$text) + if ($text === '') { return; } diff --git a/tests/text_processing/generate_text_for_display.php b/tests/text_processing/generate_text_for_display.php new file mode 100644 index 0000000000..4088e33f30 --- /dev/null +++ b/tests/text_processing/generate_text_for_display.php @@ -0,0 +1,36 @@ +optionset('viewcensors', false); + } + + public function test_empty_string() + { + $this->assertSame('', generate_text_for_display('', '', '', 0)); + } + + public function test_zero_string() + { + $this->assertSame('0', generate_text_for_display('0', '', '', 0)); + } +} From 68aa974a207b444199fabe9d754f403d27d700ad Mon Sep 17 00:00:00 2001 From: s9e Date: Sat, 3 Aug 2013 12:29:23 +0200 Subject: [PATCH 2/3] [ticket/11762] Fixed test's filename PHPBB3-11762 --- ...te_text_for_display.php => generate_text_for_display_test.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/text_processing/{generate_text_for_display.php => generate_text_for_display_test.php} (100%) diff --git a/tests/text_processing/generate_text_for_display.php b/tests/text_processing/generate_text_for_display_test.php similarity index 100% rename from tests/text_processing/generate_text_for_display.php rename to tests/text_processing/generate_text_for_display_test.php From 9db1728b4b976c99f5811e578619e37c69e306cd Mon Sep 17 00:00:00 2001 From: s9e Date: Sat, 3 Aug 2013 14:05:40 +0200 Subject: [PATCH 3/3] [ticket/11762] Added call to test class's parent::setUp(). Added call to test class's parent::setUp(). Updated copyright year. PHPBB3-11762 --- tests/text_processing/generate_text_for_display_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index 4088e33f30..a157fe7d9a 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -2,7 +2,7 @@ /** * * @package testing -* @copyright (c) 2011 phpBB Group +* @copyright (c) 2013 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -18,6 +18,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca { global $cache, $user; + parent::setUp(); + $cache = new phpbb_mock_cache; $user = new phpbb_mock_user;