[wp-trac] [WordPress Trac] #12690: Square brackets breaking links that contain square brackets

WordPress Trac noreply at wordpress.org
Wed Jul 23 13:18:34 UTC 2014


#12690: Square brackets breaking links that contain square brackets
-----------------------------------+-----------------------------
 Reporter:  iandstewart            |       Owner:  wonderboymusic
     Type:  defect (bug)           |      Status:  reopened
 Priority:  normal                 |   Milestone:  4.0
Component:  Formatting             |     Version:
 Severity:  normal                 |  Resolution:
 Keywords:  wptexturize has-patch  |     Focuses:
-----------------------------------+-----------------------------
Changes (by kovshenin):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 r28727 has too much backtracking which can cause segfaults in libpcre.

 {{{
 $text = '';
 for ( $i = 0; $i <= 300; $i++ )
     $text .= 'lorem ipsum dolor sit amet ';

 $text = '[' . trim( $text ) . ']';
 echo wptexturize( $text );

 // /var/log/syslog: Jul 23 13:40:44 debian kernel: [56656.209599]
 php5-fpm[6990]: segfault at 7fff4db6cf30 ip 00007f9a269d17ed sp
 00007fff4db6cef0 error 6 in libpcre.so.3.13.1[7f9a269be000+3c000]
 }}}

 A simple workaround would be to not backtrack to try and match an empty
 `[]` shortcode, see [attachment:12690.diff]. Here's a little
 [https://cloudup.com/cyBn_Pcynn9 perl script] if you'd like to compare the
 amount of backtracking on both variants.

 That said, we should probably be looking into using the data in
 $shortcode_tags in that regex, or even get_shortcode_regex() entirely,
 that would limit the search to the actual shortcodes that are available,
 and it will probably break so many unit tests which rely on non-existent
 shortcodes such as `[code]` or `[...]`.

 I'm running PHP 5.6.0beta3 on Debian, PCRE version 8.30 2012-02-04 with
 the default backtrack_limit of 1M. If you're having trouble reproducing,
 try increasing the number of loops.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/12690#comment:31>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list