[wp-trac] [WordPress Trac] #54828: BR tags are added to HTML widget code

WordPress Trac noreply at wordpress.org
Sat Jan 15 14:33:22 UTC 2022


#54828: BR tags are added to HTML widget code
--------------------------+-----------------------------
 Reporter:  n3wjack       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Widgets       |    Version:  5.8.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 **Steps to reproduce**:

 1. Add an HTML widget to a footer block containing a script block with
 multiple lines of JS code.
 2. Save.
 3. Refresh the page (F5)

 **Result**:

 The JS code now contains <br/> statements, breaking the code.
 When you save again, the JS will fail in the  browser.

 **Expected**:

 No extra HTML tags are added to an HTML widget.


 **Example HTML widget content:**


 {{{
 <script src='https://storage.ko-fi.com/cdn/scripts/overlay-
 widget.js'></script>
 <script>
   kofiWidgetOverlay.draw('n3wjack', {
     'type': 'floating-chat',
     'floating-chat.donateButton.text': 'Support Me',
     'floating-chat.donateButton.background-color': '#323842',
     'floating-chat.donateButton.text-color': '#fff'
   });
 </script>

 }}}

 **Example of resulting HTML code with extra HTML tags**:


 {{{
 <p><script src="https://storage.ko-fi.com/cdn/scripts/overlay-
 widget.js"></script><br>
 <script><br />
   if (document.body.classList.contains('post-template-default')) {<br />
   kofiWidgetOverlay.draw('n3wjack', {<br />
     'type': 'floating-chat',<br />
     'floating-chat.donateButton.text': '',<br />
     'floating-chat.donateButton.background-color': '#323842',<br />
     'floating-chat.donateButton.text-color': '#fff'<br />
   });<br />
 }<br />
 </script></p>
 }}}

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


More information about the wp-trac mailing list