WordPress.org

Make WordPress Core

Opened 13 months ago

Last modified 9 months ago

#23776 new defect (bug)

A string of text starting with "http://" turned into a paragraph

Reported by: winterstreet Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 2.9
Component: Embeds Keywords: needs-patch dev-feedback
Focuses: Cc:

Description

In either editor, if there's a line of text that starts with http:// wordpress will create a new paragraph.

This description box isn't working to show what I mean see this support post.

http://wordpress.org/support/topic/a-string-of-text-starting-with-http-turned-into-a-paragraph

Change History (8)

comment:1 winterstreet13 months ago

  • Cc dave@… added

comment:2 esmi13 months ago

Confirmed using Twenty Twelve & no active plugins in both Text & Visual editors. The bug appears to be triggered by any text that immediately follows http:// where http:// is at the start of a new line.

comment:3 SergeyBiryukov13 months ago

  • Component changed from General to Embeds
  • Version changed from 3.5 to 2.9

Introduced in [12023].

WP_Embed::autoembed() has a regex to catch any unlinked URLs that are on their own line:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/class-wp-embed.php#L237

WP_Embed::autoembed_callback() then adds an empty line after the URL.

comment:4 SergeyBiryukov10 months ago

#24615 was marked as a duplicate.

comment:5 Viper007Bond10 months ago

  • Cc Viper007Bond added

comment:6 garhdez9 months ago

I think that this is not a bug.

Any string (containing allowed chars) can be a correct URL. For example, "http://a" could be the URL of real server in an intranet, so I think this regex is well written, because matches any string before http:// or https:// that is not a whitespace.

comment:7 Viper007Bond9 months ago

It is a bug. :)

The intention of the embed code is to find a URL on its own line. Once found, it tries to embed it and if it is unable to, then it hyperlinks the URL. However the number of line breaks during this whole process should remain the same.

WP_Embed::autoembed_callback() returns new lines before and after the string it returns because those new lines are matched as a part of the search process.

So really the more proper solution is likely to fix the regex to find URLs on their own line but not include the line breaks in the match so that the function that returns the result won't need to include them, potentially including extra line breaks in the process.

comment:8 DrewAPicture9 months ago

  • Keywords needs-patch dev-feedback added
Note: See TracTickets for help on using tickets.