[wp-trac] [WordPress Trac] #9264: Self closing shortcodes

WordPress Trac wp-trac at lists.automattic.com
Mon Mar 2 23:06:19 GMT 2009


#9264: Self closing shortcodes
--------------------------+-------------------------------------------------
 Reporter:  rb-cohen      |       Owner:  anonymous 
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  General       |     Version:  2.7.1     
 Severity:  normal        |    Keywords:  shortcode 
--------------------------+-------------------------------------------------
 First bug report, be gentle.

 I've noticed that the shortcode regex doesn't take note of the self
 closing "/" properly, and continues to search for a closing tag within the
 content passed to it.

 I think it should stop looking for a closing tag if the tag is self
 closing. See the following example:

 {{{
 [test id="1"/] first self closed, now [test id="2"]with content[/test]
 }}}

 This gets sent to the shortcode callback function as:

 '''Attributes:''' id="1"
 '''Content:'''  first self closed, now [test id="2"]with content

 I've posted some further tests at http://blograndom.com/tests/shortcode/ ,
 to prove the bug exists and my proposed fix (see attached diff file). The
 fix also offers slight speed enhancements for self closing divs because it
 stops looking.

 It looks like the trunk version of shortcodes.php is slightly different to
 2.7.1, but I've applied the patch from the trunk version which still seems
 to have the same problem.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9264>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list