[wp-trac] [WordPress Trac] #43686: Shortcodes containing asterisks may create invalid regex breaking the editor

WordPress Trac noreply at wordpress.org
Tue Apr 3 21:31:42 UTC 2018


#43686: Shortcodes containing asterisks may create invalid regex breaking the
editor
----------------------------+-----------------------------
 Reporter:  Vusys           |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Shortcodes      |    Version:  4.9.4
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 Despite not being a reserved character an asterisk in a shortcode followed
 by another character will generate invalid regex which breaks the editor.

 This code reproduces the issue:


 {{{#!php
 <?php
 foreach (['*one', '*two'] as $bullet) {
     add_shortcode('*' . $bullet, function () use ($bullet) {
         return 'oh no ' . $bullet;
     });
 }
 }}}

 Attached is a gif showing the editor tabs not working correctly along with
 the error in the console in Chrome 65 and Firefox 59.

 I know it's unconventional to use an asterisk in a shortcode, but my use
 case is porting a legacy CMS that used BBCode into WordPress while trying
 to keep as much of the original formatting possible for old content.

 This is an issue with all plugins deactivated (except for the above code)
 using the Twenty Seventeen theme.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43686>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list