Opened 5 years ago

Last modified 3 weeks ago

#6297 reopened defect (bug)

Unbalanced tags across more and nextpage tags

Reported by: tellyworth Owned by:
Priority: normal Milestone: Awaiting Review
Component: Formatting Version: 2.5
Severity: normal Keywords: has-patch
Cc:

Description

It's easy to produce broken front page markup by including a --nextpage-- tag that breaks an enclosing bold or italic tag. There's some code in get_the_content that fixes this for --more-- tags, but it doesn't handle --nextpage--, and it'd be more efficient to do it at post save time.

The enclosed patch fixes this by splitting the content into slices at those boundaries and separately balancing each slice. Balancing happens in the content_save_pre action. No filtering is needed on the output side for posts saved after this filter.

It was a bit of a struggle figuring out where to fit this but I think the solution is fairly clean. It includes a new split_nextpage() function that can be used instead of ad-hoc regexps for splitting a post into pages.

Attachments (2)

balance-tags-with-more-r7392.patch (3.2 KB) - added by tellyworth 5 years ago.
balanceTags_quicktags-trunk.patch (825 bytes) - added by devesine 14 months ago.

Download all attachments as: .zip

Change History (16)

By "No filtering is needed on the output side" I mean no _balance_ filtering of course.

  • Milestone changed from 2.7 to 2.6
  • Version set to 2.5

comment:4   ryan5 years ago

  • Milestone changed from 2.9 to 2.7

comment:5   ryan4 years ago

  • Milestone changed from 2.7 to 2.8

ah, yes, the number of sidebar gets knocked down issues that this might fix...

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from 2.8 to Future Release

broken patch

  • Component changed from General to Formatting
  • Owner anonymous deleted
  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

fixed in r11398

  • Milestone set to Awaiting Review
  • Resolution duplicate deleted
  • Status changed from closed to reopened

Was not fixed. Unit tests are still broken. Closed #20278 as a duplicate.

Bringing over patch from #20278:

The attached patch splits up the text (using a regex patterned after the regexes used to split out quicktags in other areas such as get_the_content()) runs force_balance_tags against each part, and glues them back together.

This could be done in force_balance_tags instead, but my first thought is that force_balance_tags is a lower-level function; since it ignores options (use_balanceTags) and has no option to not balance (truism), it should ignore other WordPress-specific conceits like quicktags. Among other things, there's no expectation that it's always being used for content that should respect those quicktags (it's also used on the comment_text filter and in get_the_content() after the more and nextpage quicktags have been handled).

  • Keywords has-patch added; needs-patch removed

Closed #24191 as a duplicate.

Note: See TracTickets for help on using tickets.