Make WordPress Core

Opened 3 years ago

Last modified 16 months ago

#22946 closed defect (bug)

Default filter erroneously turns FTP hostnames into HTTP links — at Initial Version

Reported by: DavidAnderson Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0.4
Component: Formatting Keywords: close has-patch
Focuses: Cc:


The function _make_web_ftp_clickable_cb in wp-includes/formatting.php is invoked upon any hostname matching "www." or "ftp." at the beginning. It pre-pends 'http://' and makes the link clickable (i.e. wraps it in <a href="">).

As a default that makes sense for things beginning www. - but not for everything beginning ftp.

In my case, I was using the plugin WP Better Emails, and sent out an email with this line (approx):

'Here is the FTP server: ftp.example.com'

WP, by default, "helpfully" totally mangles this into:
'Here is the FTP server: <a href="http://ftp.example.com">http://ftp.example.com</a>'

The recipient of my email now believes that I was sending him an HTTP link, and is confused that it does not work. But in fact I never sent such a link - that was WordPress mangling what I did send.

Sure, some FTP servers will also have HTTP listening. But by default WordPress assumes that they all do, which is crazy.

Proposed solution: on line 1471 of wp-includes/formatting.php (as found in 3.4.2), change:

$ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w
xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );

by removing the "ftp" case, hence:

$ret = preg_replace_callback( '#([\s>])((www)\.[\w
xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );

The function _make_web_ftp_clickable_cb should then be renamed by removing ftp_, since the case of turning FTP hostnames into clickable HTTP links would have been removed.

Change History (0)

Note: See TracTickets for help on using tickets.