[wp-trac] Re: [WordPress Trac] #8553: preg_replace_callback in do_shortcode returns empty for large posts

WordPress Trac wp-trac at lists.automattic.com
Tue Jun 16 23:08:40 GMT 2009

#8553: preg_replace_callback in do_shortcode returns empty for large posts
 Reporter:  AaronCampbell  |        Type:  defect (bug)
   Status:  new            |    Priority:  high        
Milestone:  2.9            |   Component:  Shortcodes  
  Version:                 |    Severity:  normal      
 Keywords:  needs-patch    |  
Changes (by Brusdeylins):

 * cc: Brusdeylins (added)
  * priority:  normal => high



 the resolution is descibed on my website (in german):

 The problem is in shortcodes.php in the function get_shortcode_regex().
 Here the RegEx has a non-greedy part between the brackets, which should
 exclude the closing bracket. This would reduce the memory usage of the
 backtracking process in the RegEx-Engine (the reason of this problem).

 My solution for the last line of this function looks like this (WordPress
 return '(.?)\[('.$tagregexp.')\b([^\]]*?)(\/)?\](?:(.+?)\[\/\2\])?(.?)';

 Here I also removed the non-catching brackets around the catching brackets
 around the slash after the non-greedy area... Don't know why these are

Ticket URL: <http://core.trac.wordpress.org/ticket/8553#comment:32>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list