WordPress.org

Make WordPress Core

#24615 closed defect (bug) (duplicate)

Non-embedded urls in paragraphs are rendered as paragraphs.

Reported by: mfields Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9
Component: Embeds Keywords:
Focuses: Cc:

Description

When a URL is on it's own line and mixed in with other text on lines before and after, WordPress gives the link it's own paragraph instead of including it inside the paragraph suggested by the surrounding text. Here is a better explanation with code samples:

Enter the following text into the visual or text tabs of the post editor:

one
two
http://three.me/
four
five

The content will display as intended in each editor. The issue occurs when it is displayed on the front end. It's expected that markup similar to the following will be generated: one paragraph with 4 <br />s separating each of the five lines.

<p>
one<br />
two<br />
<a href="http://three.me/" rel="nofollow">http://three.me/</a><br />
four<br />
five
</p>

Instead, the following markup is produced. 3 unique paragraphs are created - one for the URL and one for each bit of content before and after the URL.

I've tested with trunk and wp3.2 locally and I get a similar markup (only the url is not linked):

<p>one<br />two</p>
<p>http://three.me/</p>
<p>four<br />five</p>

I've tested this both in the latest trunk as well as 3.2.1 with the same result.

Change History (2)

comment:1 Viper007Bond10 months ago

  • Keywords needs-patch added

This is due to WP_Embed trying to embed the URL. When it returns, it does return "\n$return\n"; which IIRC was because the regex is including new lines in it's match and so that's there to prevent stripping them during the process of matching and replacing.

Looks like there's a bug in the logic though because it shouldn't be resulting in extra line breaks being introduced.

Last edited 10 months ago by Viper007Bond (previous) (diff)

comment:2 SergeyBiryukov10 months ago

  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version changed from 3.2 to 2.9

Duplicate of #23776.

Note: See TracTickets for help on using tickets.