Make WordPress Core

Opened 15 years ago

Closed 11 years ago

#18776 closed defect (bug) (maybelater)

balanceTags should ignore shortcodes & their content

Reported by: ciantic Owned by:
Priority: normal Milestone:
Component: Shortcodes Version: 3.2.1
Severity: normal Keywords:
Cc: Focuses:

Description

Take following input:

something [myshortcode]<b>[/myshortcode]

after balanceTags() it becomes:

something [myshortcode]<b>[/myshortcode]</b>

Well, this is not what the shortcode creator probably wanted.

Proposed fixes:

If you are feeling lazy: Convert [.*] to <$1> and since balanceTags handles XML it should work, afterwards convert appropriate <> back to []. Though this does not give a shortcode creator chance to disallow balancing tags inside it's content which is bad.

Better fix is to allow shortcode creators to decide wether their contents should be balanced:

  1. balanceTags() should ignore all shortcodes and their contents.
  2. Parse all shortcodes in content and on each shortcode call apply filter on so that shortcode creator can hook (if sees it appropriate) on to that. Shortcode creator then can call balanceTags() in his filter of that shortcode in order to run balanceTags() contents of shortcode separately if wanted.

Attachments (2)

18776.unit-test.diff (591 bytes ) - added by MikeHansenMe 12 years ago.
Unit tests using example provided
18776.unit-test.2.diff (665 bytes ) - added by aaroncampbell 12 years ago.

Download all attachments as: .zip

Change History (7)

#1 @coffee2code
14 years ago

  • Keywords needs-patch added
  • Milestone Awaiting ReviewFuture Release
  • Version3.2.1

#2 @nacin
13 years ago

  • Keywords needs-unit-tests 2nd-opinion added

It's pretty clear there hasn't been much of an appetite for dealing with this. That said, there have been some balanceTags improvements in the last few years, so it's possible to revisit this.

Any changes here will also need unit tests.

@MikeHansenMe
12 years ago

Unit tests using example provided

#3 @MikeHansenMe
12 years ago

  • Keywords needs-unit-tests removed

#4 @aaroncampbell
12 years ago

I also thought we should have a test to make sure that
something <b>[myshortcode]<b>[/myshortcode] becomes
something <b>[myshortcode]<b>[/myshortcode]</b>

I added that in 18776.unit-test.2.diff and also moved the unit test and grouped it with the other balanceTags ones since that's what we're really testing

#5 @miqrogroove
11 years ago

  • Keywords needs-patch 2nd-opinion removed
  • Milestone Future Release
  • Resolutionmaybelater
  • Status newclosed

Garbage in, garbage out. No traction.

Note: See TracTickets for help on using tickets.