From cd7ee44fd2ec09c853b0ee0d48d6ee5d3d78c2d1 Mon Sep 17 00:00:00 2001 From: e107steved Date: Sat, 3 Mar 2007 19:41:17 +0000 Subject: [PATCH] Bugtracker #3819 - process/strip bbcodes in poll titles --- e107_handlers/bbcode_handler.php | 23 ++++++++++++++++++++--- e107_plugins/poll/oldpolls.php | 16 +++++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index e0a5651cf..85b4d9ff1 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -12,8 +12,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/bbcode_handler.php,v $ -| $Revision: 1.6 $ -| $Date: 2007-02-26 20:23:39 $ +| $Revision: 1.7 $ +| $Date: 2007-03-03 19:40:53 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -62,7 +62,9 @@ class e_bbcode - function parseBBCodes($value, $p_ID, $force_lower = 'default') +// If $bb_strip is TRUE, all bbcodes are stripped. If FALSE, none are stripped. +// If a comma separated (lower case) list is passed, only the listed codes are stripped (and the rest are processed) + function parseBBCodes($value, $p_ID, $force_lower = 'default', $bb_strip = FALSE) { global $postID; $postID = $p_ID; @@ -74,6 +76,12 @@ class e_bbcode $result = ''; // Accumulates fully processed text $stacktext = ''; // Accumulates text which might be subject to one or more bbcodes $nopro = FALSE; // Blocks processing within [code]...[/code] tags + + $strip_array = array(); + if (!is_bool($bb_strip)) + { + $strip_array = explode(',',$bb_strip); + } $pattern = '#^\[(/?)([A-Za-z]+)(\d*)([=:]?)(.*?)]$#i'; // Pattern to split up bbcodes // $matches[0] - same as the input text // $matches[1] - '/' for a closing tag. Otherwise empty string @@ -99,6 +107,13 @@ class e_bbcode if ($nopro && ($bbword == 'code') && ($matches[1] == '/')) $nopro = FALSE; // End of code block if (($bbword) && ($bbword == trim($bbword)) && !$nopro) { // Got a code to process here + if (($bb_strip === TRUE) || in_array($bbword,$strip_array)) + { + $is_proc = TRUE; // Just discard this bbcode + } + else + { + if ($matches[1] == '/') { // Closing code to process $found = FALSE; @@ -175,6 +190,8 @@ class e_bbcode $is_proc = TRUE; } } + + } } // Next lines could be deleted - but gives better rejection of 'stray' opening brackets if ((!$is_proc) && (($temp = strrpos($cont,"[")) !== 0)) diff --git a/e107_plugins/poll/oldpolls.php b/e107_plugins/poll/oldpolls.php index 16f5b5b0f..0f462f3e1 100644 --- a/e107_plugins/poll/oldpolls.php +++ b/e107_plugins/poll/oldpolls.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/poll/oldpolls.php,v $ -| $Revision: 1.2 $ -| $Date: 2007-02-16 20:48:37 $ +| $Revision: 1.3 $ +| $Date: 2007-03-03 19:41:00 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -58,8 +58,8 @@ if(e_QUERY) $text = " @@ -137,10 +137,12 @@ foreach($oldpollArray as $oldpoll) $from = $gen->convert_date($poll_datestamp, "short"); $to = $gen->convert_date($poll_end_datestamp, "short"); + $poll_title = $tp->e_bb->parseBBCodes($poll_title, 0,TRUE,TRUE); // Strip bbcodes + $text .= " - - - + + + \n"; }
- ".$tp -> toHTML($poll_title)." -
".POLLAN_35." ".$user_name.".
".POLLAN_37." ".$start_datestamp." ".POLLAN_38." ".$end_datestamp.".
".POLLAN_26.": $voteTotal
+ ".$tp -> toHTML($poll_title,TRUE,'TITLE')." +
".POLLAN_35." ".$user_name.".
".POLLAN_37." ".$start_datestamp." ".POLLAN_38." ".$end_datestamp.".
".POLLAN_26.": {$voteTotal}

$poll_title$user_name$from ".POLLAN_38." $to{$poll_title}{$user_name}{$from} ".POLLAN_38." {$to}