[Bb-trac] Re: [bbPress] #795: posts re-saved with non-ending html tags are improperly handled (has fix)

bbPress bb-trac at lists.bbpress.org
Thu Feb 28 12:08:03 GMT 2008


#795: posts re-saved with non-ending html tags are improperly handled (has fix)
----------------------+-----------------------------------------------------
 Reporter:  _ck_      |        Owner:       
     Type:  defect    |       Status:  new  
 Priority:  high      |    Milestone:  0.8.4
Component:  Back-end  |      Version:       
 Severity:  major     |   Resolution:       
 Keywords:            |  
----------------------+-----------------------------------------------------
Changes (by _ck_):

  * priority:  normal => high
  * summary:  posts re-saved with non-ending html tags are improperly
              handled => posts re-saved with non-ending html
              tags are improperly handled (has fix)
  * milestone:  => 0.8.4

Comment:

 Apparently the problem lies within bb_encode_bad.
 Here is an enhanced tested fix:

 {{{
 function bb_encode_bad( $text ) {
         $text = wp_specialchars( $text );
         $text = preg_replace("|&lt;br\s*?/*?&gt;|", "<br />", $text);
         foreach ( bb_allowed_tags() as $tag => $args ) {
                 if ( 'br' == $tag )
                         continue;
                 if ('hr'==$tag || 'img'==$tag)
                         $text = preg_replace("|&lt;$tag\s*?/*?&gt;|",
 "<$tag />", $text);
                 elseif ( $args )
                         $text = preg_replace("|&lt;(/?$tag.*?)&gt;|",
 '<$1>', $text);
                 else
                         $text = preg_replace("|&lt;(/?$tag)&gt;|", '<$1>',
 $text);
         }

         return $text;
 }
 }}}

-- 
Ticket URL: <http://trac.bbpress.org/ticket/795#comment:1>
bbPress <http://bbpress.org/>
Innovative forum development


More information about the Bb-trac mailing list