[wp-trac] [WordPress Trac] #33102: Shortcodes with Quoted Attributes Break Inside of Quoted HTML Attributes

WordPress Trac noreply at wordpress.org
Fri Jul 24 19:45:29 UTC 2015


#33102: Shortcodes with Quoted Attributes Break Inside of Quoted HTML Attributes
--------------------------+------------------------------
 Reporter:  cgrymala      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Shortcodes    |     Version:  4.2.3
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+------------------------------

Comment (by iamfriendly):

 I wanted to give an exact example using the Accordion Shortcode
 (https://wordpress.org/plugins/accordion-shortcode/) which is pretty
 popular;


 {{{
 [accordions collapsible=true active=false style=accordion-container]
  [accordion title="section 1" style="accordion-style1 [author]"]
   content [author]
  [/accordion]
  [accordion title="section 2" style="accordion-style2"]
   more content
  [/accordion]
 [/accordions]
 }}}

 Here, what I would expect - and is happening on 4.2.2 -

 {{{
 <div id="random-accordion-id-400" class="accordion-shortcode accordion
 accordion-container">

         <div class="accordion-group">
                 <div class="accordion-heading">
                         <a href="#section-1-0" class="accordion-toggle
 accordion-style1 ADMIN" data-toggle="collapse" data-parent="#random-
 accordion-id-400">section 1</a>
                 </div>
                 <div id="section-1-0" class="accordian-shortcode-content
 accordion-body collapse" style="height: 0px;">
                         <div class="accordion-inner">
                                 <p>content ADMIN</p>
                         </div>
                 </div>
         </div>

         <div class="accordion-group">
                 <div class="accordion-heading">
                         <a href="#section-2-1" class="accordion-toggle
 accordion-style2 focus" data-toggle="collapse" data-parent="#random-
 accordion-id-400">section 2</a>
                 </div>
                 <div id="section-2-1" class="accordian-shortcode-content
 accordion-body in collapse" style="height: auto;">
                         <div class="accordion-inner">
                                 <p>more content</p>
                         </div>
                 </div>
         </div>

 </div>
 }}}

 You can see that the [author] shortcode has been replaced by ADMIN (I
 added the caps to make it more easily read) in the two places - one as an
 attribute and one as part of the content. However, what I'm seeing in
 4.2.3 is the following;

 {{{
 <div id="random-accordion-id-400" class="accordion-shortcode accordion
 accordion-container">

         <div class="accordion-group">
                 <div class="accordion-heading">
                         <a href="#section-1-0" class="accordion-toggle"
 data-toggle="collapse" data-parent="#random-accordion-id-400">section
 1</a>
                 </div>
                 <div id="section-1-0" class="accordian-shortcode-content
 accordion-body collapse" style="height: 0px;">
                         <div class="accordion-inner">
                                 <p>"]<br>content admin</p>
                         </div>
                 </div>
         </div>

         <div class="accordion-group">
                 <div class="accordion-heading">
                         <a href="#section-2-1" class="accordion-toggle
 accordion-style2 focus" data-toggle="collapse" data-parent="#random-
 accordion-id-400">section 2</a>
                 </div>
                 <div id="section-2-1" class="accordian-shortcode-content
 accordion-body in collapse" style="height: auto;">
                         <div class="accordion-inner">
                                 <p>more content</p>
                         </div>
                 </div>
         </div>

 </div>
 }}}

 The shortcode in the attribute is missed. the one in the content exists,
 however, the content is prefixed with `"]<br>`

 This is an example of nested shortcodes breaking, regardless of how you
 use quotes (I've tried with both single and double quotes for the  `style`
 attribute. Both produce the same result (apart from when using single
 quotes, the content is prefixed with `']<br>` and not `"]<br>` )

 Sadly, I'm aware that using shortcodes like this was never an expected
 behaviour. But, in our case (across several hundred sites) and many, many
 others, this is something that people are doing.

 I'm really keen to help out with a fix on this, so if anyone can point me
 in the right direction I'll happily get my hands dirty.

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


More information about the wp-trac mailing list