WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 4 years ago

Last modified 4 years ago

#6870 closed defect (bug) (fixed)

Nest Q[uotation] elements mishandled by preprocessor, possibly trashing entry.

Reported by: oeconomist Owned by: nacin
Milestone: 3.3 Priority: normal
Severity: normal Version: 2.5.1
Component: Formatting Keywords: has-patch commit
Focuses: Cc:

Description

In HTML, one is allowed to nest Q[uotation] elements within Q[uotation] element. The WordPress editor sees nested quotation elements as in error, and attempts to fix things by closing the outer element when it reaches the inner element. I note also that a spurious DIV-closing tag may be placed at the end of an entry containing nested Q[uotation] elements, causing the rest of the 'blog page to be rendered incorrectly. Users are forced either to forgo best HTML practice, or to bypass the WordPress editor to fix the entry.

(Bug was also found in Version 2.5.)

Attachments (1)

6870.diff (705 bytes) - added by solarissmoke 4 years ago.
q elements are nestable

Download all attachments as: .zip

Change History (23)

comment:1 @matt7 years ago

  • Keywords wpautop added; Q[uotation] element removed
  • Milestone changed from 2.7 to 2.9

comment:2 @Denis-de-Bernardy6 years ago

  • Component changed from General to Formatting
  • Owner anonymous deleted

comment:3 @ryan5 years ago

  • Milestone changed from 2.9 to Future Release

comment:4 @solarissmoke4 years ago

  • Keywords posting editor wpautop removed
  • Resolution set to worksforme
  • Status changed from new to closed

Assuming this ticket is referring to nested blockquote elements - it seems to work fine in trunk, wpautop doesn't mess them up.

comment:5 @dd324 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Assuming this ticket is referring to nested blockquote elements -

I believe it was refering to the inline variant, the <q>..</q> Quotation element, can you re-test with that one too?

comment:6 @solarissmoke4 years ago

Tested with nested inline quote tags as below and that also works fine:

<q>This is a quotation that quotes <q>another quotation</q> inside it.</q>

comment:7 @solarissmoke4 years ago

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

Feel free to reopen if there is an issue.

comment:8 @dd324 years ago

  • Milestone Future Release deleted

most likely fixed with one of the many formatting updated over the versions. thanks for testing :)

comment:9 @oeconomist4 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

It is still broken on WordPress 3.1.3 running on my host. If it's fixed in some forthcoming version, that's cool. It the test was run on 3.1.3, then the reason for different behaviors needs to be explored.

comment:10 @solarissmoke4 years ago

  • Keywords reporter-feedback added

I tested using the code in comment:6, and it works fine in 3.1.3. Please post a code snippet that breaks for you.

Note that inserting line breaks in between the tags will cause problems with wpautop - but that is a wider autop issue that affects all inline tags.

comment:11 follow-up: @oeconomist4 years ago

solarissmoke—

The very string that you present above

<q>This is a quotation that quotes <q>another quotation</q> inside it.</q>

breaks for me.

Is it possible that your inline-quote plugin causes your installation to handle nested quotations correctly, while a bare installation will not?

comment:12 in reply to: ↑ 11 @solarissmoke4 years ago

Replying to oeconomist:

Is it possible that your inline-quote plugin causes your installation to handle nested quotations correctly, while a bare installation will not?

Nope, I'm testing on a fresh checkout of 3.1.3 with no plugins installed :). What is that string being converted to in your output html?

comment:13 @oeconomist4 years ago

A post with nothing but that string entered becomes

<p><q>This is a quotation that quotes </q><q>another quotation</q> inside it.</p>

which is then unsurprisingly rendered as

“This is a quotation that quotes ”“another quotation” inside it.

In other words, just as originally reported, the outer quotation is closed when the inner quotation is encountered.

comment:14 @solarissmoke4 years ago

  • Keywords reporter-feedback removed

Ah, found the problem. It's with balance_tags.

Last edited 4 years ago by solarissmoke (previous) (diff)

@solarissmoke4 years ago

q elements are nestable

comment:15 @solarissmoke4 years ago

  • Keywords has-patch added

comment:16 @ocean904 years ago

  • Milestone set to Future Release

comment:17 @oeconomist4 years ago

*sigh*

“No comment.”

comment:18 @coffee2code4 years ago

+1

I was responsible for the introduction of the self-nesting tag handling in balance_tags(). The omission of the <q> tag was an oversight (for the life of me I can't find where I added a patch to rectify that lo those many years ago). Anyhow, the change is trivial and has no negative side effects.

As further proof as to whether the <q> tag is self-nestable, the W3C itself does so in an example in the HTML 4.01 spec section pertaining to <q> here.

comment:19 @nacin4 years ago

  • Keywords commit needs-unit-tests added
  • Milestone changed from Future Release to 3.3

comment:20 @nacin4 years ago

#1170 - that's an old one.

comment:21 @nacin4 years ago

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

In [18585]:

Add 'q' tag to nestable tags list in force_balance_tags(). props solarissmoke, fixes #6870.

Note: See TracTickets for help on using tickets.