Make WordPress Core

Opened 20 years ago

Closed 17 years ago

Last modified 4 years ago

#1170 closed defect (bug) (fixed)

Nested blockquotes unallowed?

Reported by: anonymousbugger's profile anonymousbugger Owned by: ryan's profile 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 19 years ago.
bug1170_functions-formatting2.diff (1.3 KB) - added by anonymousbugger 19 years ago.
1170.diff (1.3 KB) - added by Nazgul 17 years ago.

Download all attachments as: .zip

Change History (26)

#1 @anonymousbugger
20 years ago

  • Patch set to No

#2 @anonymousbugger
20 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.

#3 @anonymousbugger
20 years ago

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

#4 @MC_incubus
20 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.

#5 @anonymousbugger
20 years ago

well what about this ?

#6 @coffee2code
20 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?

#7 @coffee2code
20 years ago

  • Patch changed from No to Yes

#8 @MC_incubus
20 years ago

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

#9 @coffee2code
20 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

#10 @mdawaffe
18 years ago

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

bug1170_functions-formatting2.diff looks good.

#11 @matt
18 years ago

  • Milestone changed from 2.1 to 2.2

#12 @rob1n
18 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.

#13 @rob1n
18 years ago

  • Milestone 2.2 deleted

#14 @link92
17 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>

#15 @Nazgul
17 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.

#16 @link92
17 years ago

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

#17 @intoxination
17 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.

#18 @foolswisdom
17 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.

@Nazgul
17 years ago

#19 @Nazgul
17 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.

#20 @rob1n
17 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

gziolo commented on PR #1171:


4 years ago
#22

I have just tested https://github.com/WordPress/gutenberg/pull/30122 to confirm that everything was applied correctly and it works as expected.

gziolo commented on PR #1171:


4 years ago
#23

I applied a few tweaks to the configuration. It should be good to go after some addition testing.

peterwilsoncc commented on PR #1171:


4 years ago
#24

Committed in https://core.trac.wordpress.org/changeset/50678

The trac ticket remains open in case anything is discovered between the release candidate and release proper.

Note: See TracTickets for help on using tickets.