[wp-trac] [WordPress Trac] #17657: Shortcode regex doesn't allow for hyphens in shortcode name

WordPress Trac wp-trac at lists.automattic.com
Thu Jun 2 04:55:21 UTC 2011


#17657: Shortcode regex doesn't allow for hyphens in shortcode name
-------------------------+-------------------------------------------------
 Reporter:  sivel        |      Owner:
     Type:  defect       |     Status:  new
  (bug)                  |  Milestone:  Awaiting Review
 Priority:  normal       |    Version:  3.2
Component:  Shortcodes   |   Keywords:  needs-patch dev-feedback 2nd-
 Severity:  normal       |  opinion
-------------------------+-------------------------------------------------
 I found an issue where I wanted to use a string in a post for specifying a
 lightbox style "album" that looked like a shortcode.

 The code I was using looked something like:

 {{{
 <a href="http://example.org/image.jpg" rel="lightbox[album-123]">Image</a>
 }}}

 Another plugin was installed that had registered a shortcode for "album".
 due to the '\b' in the regex the '-' is seen as the ending delimiter in
 the shortcode name, and the callback for 'album' was processed at this
 point.

 I of course corrected the issue by prefixing the "album" name with a
 unique string, however I am thinking that we should perhaps update the
 regex so that some common characters often seen in strings for readability
 without spaces.

 Plugin code to test:
 {{{
 add_shortcode('broken', 'broken');

 function broken() {
         return 'Running the broken shortcode';
 }
 }}}

 and then in a post:
 {{{
 [broken-shortcode]
 }}}

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


More information about the wp-trac mailing list