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

Poll options preview rendered incorrectly by <br /> collision

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Trivial Trivial
    • 3.0.14-RC1, 3.1.4-RC1, 3.2.0-a1
    • 3.0.13
    • Posting
    • None
    • PHP 5.4.7

      1. Create a custom BBCode (i.e. [br][/br]) that renders to <br />
      2. Create/edit one poll option using that BBCode
      3. Preview the poll (with its option)
      You'll see it renders as two options instead of one option. The culprit is in \posting.php:

      $parse_poll->message = implode("\n", $post_data['poll_options']);
      $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']);
      $preview_poll_options = explode('<br />', $parse_poll->message);

      The last line wrongly assumes <br /> is a unique translation of "\n", but that is not true anymore once a BBCode translates to <br /> aswell, leading to cut one poll option into multiple.

      A more than obvious fix is to parse each poll option on it's own by simply replacing the code above with:

      $preview_poll_options= array();
      foreach( $post_data['poll_options'] as $iPollOption=> $sPollOption ) {
      	$parse_poll-> message= $sPollOption;
      	$parse_poll-> format_display( $post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'] );
      	$preview_poll_options[$iPollOption]= $parse_poll-> message;
      }

      Tested successfully.

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

              Created:
              Updated:
              Resolved: