Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-11216

generate_text_for_display() improper auto-typecast

XMLWordPrintable

      Function generate_text_for_display() in /includes/functions_content.php is checking too loosely on the parameter $text:

      	if (!$text)
      	{
      		return '';
      	}

      This won't give back any result if $text has the value "0", since PHP automatically tries to cast strings to integers. That's the reason why "0" == FALSE and !"0" == TRUE and the function thinks the string is empty.

      The correct code should be:

      	if ($text === '')
      	{
      		return '';
      	}

      The bug is trivial, but this function is used in many places.
      Reaction to https://www.phpbb.com/community/viewtopic.php?f=71&t=2165721&p=13201648#p13201648

            Oleg Oleg [X] (Inactive)
            AmigoJack AmigoJack
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: