WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 7 years ago

#1170 closed defect (bug) (fixed)

Nested blockquotes unallowed?

Reported by: anonymousbugger Owned by: ryan
Milestone: 2.3 Priority: normal
Severity: minor Version: 2.2
Component: General Keywords: has-patch commit
Focuses: Cc:

Description

I want to put nested blockquotes -- which is allowed in XHTML 1.0 (all flavors) -- into a post. However, the blockquote tag is being closed automatically before the nested blockquote tag.

Attachments (3)

bug1170_functions-formatting.php (684 bytes) - added by anonymousbugger 9 years ago.
bug1170_functions-formatting2.diff (1.3 KB) - added by anonymousbugger 9 years ago.
1170.diff (1.3 KB) - added by Nazgul 7 years ago.

Download all attachments as: .zip

Change History (22)

comment:1 anonymousbugger9 years ago

  • Patch set to No

comment:2 anonymousbugger9 years ago

The problem is in the wpautop() function in functions-formatting.php

The problem can be circumvented by disabling "WordPress should correct invalidly nested XHTML automatically" under "Options > Writing"

Of course a fix would be preferable to avoidance.

comment:3 anonymousbugger9 years ago

Actually, ignore my previous comment, it's in balanceTags() on line 328.

comment:4 MC_incubus9 years ago

Honestly, balanceTags() ("WordPress should correct invalidly nested XHTML automatically") is more trouble than it is worth for people who know how to close tags and want to do more than <em> and <strong> markup.

comment:5 anonymousbugger9 years ago

well what about this ?

comment:6 coffee2code9 years ago

balanceTags() in its present incarnation will likely never ensure 100% XHTML-ization of posts. In this example, you trip an uncommon(?) situation where a tag is allowed to be immediately nested within itself. balanceTags() already allows for this for [div]. I've attached a patch that also allows it for [blockquote]. Any other situations like this that anyone can think of?

comment:7 coffee2code9 years ago

  • Patch changed from No to Yes

comment:8 MC_incubus9 years ago

  • Owner changed from anonymous to rboren
  • Status changed from new to assigned

comment:9 coffee2code9 years ago

I suppose 'span' might be another immediately nestable tag. I've attached a revised patch, bug1170_functions-formatting2.diff which adds it. I've also shorted two condition statements (which are within a while loop) by defining $single_tags and $nestable_tags arrays at the start of the function and using in_array() for the checks. Hopefully that's slightly more efficient, but at the very least should clarify what it's doing.

edited on: 04-22-05 13:57

comment:10 mdawaffe8 years ago

  • Keywords has-patch 2nd-opinion added
  • Milestone set to 2.1

bug1170_functions-formatting2.diff looks good.

comment:11 matt7 years ago

  • Milestone changed from 2.1 to 2.2

comment:12 rob1n7 years ago

  • Resolution set to worksforme
  • Status changed from assigned to closed

Works for me, running 2.1.

Unless you mean the quicktags (the formatting buttons), but that's clumsy to get around.

comment:13 rob1n7 years ago

  • Milestone 2.2 deleted

comment:14 link927 years ago

  • Milestone set to 2.3
  • Resolution worksforme deleted
  • Status changed from closed to reopened

This is not fixed. If you're unable to recreate this (which really isn't have hard, as all you do is nest a blockquote within another), here's a simple how to:

  1. Create a new post
  2. As the content, put <blockquote><blockquote><p>Can you quote me?</p></blockquote><p>Look, I can quote you!</p></blockquote>
  3. Save.
  4. Observe it being changed to <blockquote></blockquote><blockquote><p>Can you quote me?</p></blockquote><p>Look, I can quote you!</p>

comment:15 Nazgul7 years ago

  • Milestone 2.3 deleted
  • Resolution set to worksforme
  • Status changed from reopened to closed

On what version does that hapen? I just tried your snippet on trunk:

In:

<blockquote><blockquote><p>Can you quote me?</p></blockquote><p>Look, I can quote you!</p></blockquote>

Out:

<blockquote><blockquote>
<p>Can you quote me?</p>
</blockquote>
<p>Look, I can quote you!</p>
</blockquote>

Which appears correct to me.

comment:16 link927 years ago

2.0.10, 2.2, and trunk, in the text editor.

comment:17 intoxination7 years ago

This still exists in 2.2. If a post runs through BlanaceTags, it removes the nesting on BlockQuotes.

This patch also works great for fixing it.

comment:18 foolswisdom7 years ago

  • Keywords 2nd-opinion removed
  • Milestone set to 2.3
  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Version changed from 1.5 to 2.2

Jamie Holly (intoxination) provided more information to the wp-hackeres mailing list. Thank you!

It still exists

in 2.2. Basically if you have a post that contains nested quotes it will
remove the nesting once it runs through balanceTags. For example this:

Hey Now

<blockquote>Your
<blockquote>An</blockquote>
All</blockquote>
Star

Running through balanceTags changes to this:

<p>Hey Now</p>
<blockquote><p>Your</p>
</blockquote>
<blockquote><p>An</p>
</blockquote>
<p>All</p>
<p>Star</p>

I manually applied the patch attached to the ticket to 2.2 and it did fix
it.

The problem occurs when saving a post with "WordPress should correct
invalidly nested XHTML automatically" checked. Since the content goes
through the balanceTags filter on content_save_pre it only applies at
save/publish time.

Nazgul7 years ago

comment:19 Nazgul7 years ago

  • Keywords commit added

That explains why I couldn't reproduce it, as "WordPress should correct invalidly nested XHTML automatically" is turned of on my blog.

I've confirmed the bug and also the fix.

The patch I attached is a refresh of the already exiting one against trunk.

comment:20 rob1n7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [5623]) Fix nestable HTML, including <blockquote>'s. Props anonymousbugger (!) and Nazgul. fixes #1170

Note: See TracTickets for help on using tickets.