Opened 7 years ago
Last modified 8 days ago
#40958 new defect (bug)
force_balance_tags breaks Ninjaforms and probably other plugins that output html within js.
Reported by: | programmin | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.7.4 |
Component: | Shortcodes | Keywords: | |
Focuses: | ui, administration | Cc: |
Description
If you have a shortcode for Ninjaforms and use the post in a context that runs force_balance_tags() it seriously breaks the script. For example if you have a form id=14, add this :
<?php echo 'NO BALANCE:--'. apply_filters('the_content', '[ninja_form id=14]' ) .' --END NO BALANCE. '; echo 'BALANCED:--'. force_balance_tags(apply_filters('the_content', '[ninja_form id=14]' )) .' --END BALANCED. ';
Notice that some ending /spans, /is, and or /as are added before the end script, breaking it. Seems to not be wp version dependent.
Change History (5)
#4
@
7 weeks ago
Does anyone have some example output before and after force-balancing the tags? I've been exploring replacing the internal logic of force_balance_tags()
with the HTML API, which should resolve pretty much every problem associated with it, but I want to verify that in this case, that there's not something strange going on with the interplay of the HTML produced by the shortcode.
https://github.com/WordPress/wordpress-develop/pull/7409
Notice that some ending /spans, /is, and or /as are added before the end script, breaking it. Seems to not be wp version dependent.
This is the part I'd love to see, since I don't have a test setup for ninja forms, nor would I know if what I see is what you are seeing.
This ticket was mentioned in Slack in #meta by clorith. View the logs.
3 weeks ago
This ticket was mentioned in Slack in #meta by dev_pro. View the logs.
2 weeks ago
#9
@
8 days ago
@sparkopro I'm not seeing your comments here now, but I still have the emails from when they came in, and I'm struggling to see where the problems are. for instance, <ul><li>Item 1<li>Item 2</ul>
was given as an input with <ul><li>Item 1</li><li>Item 2</li></ul>
as the output – this seems correct according to the intention of force_balance_tags()
.
I was thinking that @programmin might be reporting a defect in the way that force_balance_tags()
operates, but I think there's a chance I've misunderstood, and there's a complaint about the general goal of transforming partially-omitted markup into well-formed markup. is that right? such as, there's partial HTML whose closers are provided by some shortcode?
<li>It’s not here[my-closing-list-tag]
where [my-closing-list-tag]
is rendered as </li>
, and whereby force_balance_tags()
closes the <li>
before the shortcode is processed?
It would be nice if there were a filter always applied at the end of the force balance function, for the possibility of cleaning up bugs like this.