From 8a02db317ef3c2d3c4e3dcfc5f8b85397f7ebb4a Mon Sep 17 00:00:00 2001 From: s9e Date: Sat, 3 Aug 2013 12:20:52 +0200 Subject: [PATCH] [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)); + } +}