Make WordPress Core

Opened 15 years ago

Last modified 5 years ago

#11678 new defect (bug)

wpautop() fails on uppercase closing tags

Reported by: joehoyle's profile joehoyle Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9
Component: Formatting Keywords: has-patch dev-feedback
Focuses: administration Cc:

Description

To reproduce, in a post enter:

<p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</P>

View the post (source) and you get:

<p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</P></p>

Because I (incorrectly) entered an uppercase closing </P> tag, wpautop() thinks there is no closing tag so adds a </p>, which then often renders as a double <p> tag. Close if this is not a bug, though I thought it may be good to do some sanitizing or something on uppercase tags.

Attachments (2)

11678.case-insensitive-regex.patch (3.9 KB) - added by kurtpayne 13 years ago.
Changing regexes to use case-insensitive modifier
11678.lowercase-tagnames.patch (531 bytes) - added by kurtpayne 13 years ago.
Change text to use lowercase tagnames

Download all attachments as: .zip

Change History (11)

#1 @joehoyle
15 years ago

I noticed if you switch between HTML and Visual in the editor it changes it to lowercase, however I ran into this problem when I imported several thousand posts, so the editor was not used

#2 follow-ups: @azaozz
15 years ago

  • Keywords reporter-feedback added; wpautop removed

Upper case tags haven't been in use for 6-7 years I think. They are also invalid with most current doctypes and the visual editor would always convert them to lower case.

In that terms adding support to wpautop() for upper case tags would only introduce unneeded overhead. It seems the best solution for this is to replace all upper case tags while importing or directly in the database after importing. That would make your content futureproof too.

Did you use one of the build-in importers? If this is a common problem we need to fix the importer or perhaps can make a small plugin to do that automatically after import.

#3 in reply to: ↑ 2 @nacin
15 years ago

Replying to azaozz:

Upper case tags haven't been in use for 6-7 years I think. They are also invalid with most current doctypes

Sadly, in (non-X)HTML 5, tag names are case insensitive and uppercase is valid.

#4 in reply to: ↑ 2 @joehoyle
15 years ago

Did you use one of the build-in importers? If this is a common problem we need to fix the importer or perhaps can make a small plugin to do that automatically after import.

No, it was a custom import from a bespoke old CMS, I have changed it to convert tags to lowercase, I just created the issue incase any other the devs thought it was something worth fixing. Feel free to close as invalid, though I think nacin does raise a good point, that in HTML 4 Uppercase tags are valid.

#5 @nacin
15 years ago

  • Keywords reporter-feedback removed
  • Milestone changed from Unassigned to Future Release

#6 @wojtek.szkutnik
14 years ago

  • Keywords gsoc added

@kurtpayne
13 years ago

Changing regexes to use case-insensitive modifier

@kurtpayne
13 years ago

Change text to use lowercase tagnames

#7 @kurtpayne
13 years ago

  • Cc kpayne@… added
  • Keywords has-patch dev-feedback added

Looks like there's two ways to handle it.

1.) Fix the text to have lowercase tag names before performing the transformations. This makes the most sense to me since the text is being changed anyway and the patch is minimally invasive.

2.) Change the regular expressions to be case insensitive. The performance overhead should be negligible. My latest profiles show that wpautop() is being called ~11 times. This patch added ~0.6ms compared to a previous profile. This patch is more invasive, but the output may more closely resemble the original text.

I've submitted a patch for each approach. Let me know what you think.

#8 @nacin
11 years ago

  • Component changed from Template to Formatting
  • Keywords wpautop added

#9 @chriscct7
9 years ago

  • Focuses administration added
  • Keywords gsoc wpautop removed
  • Severity changed from minor to normal
Note: See TracTickets for help on using tickets.