Default filter erroneously turns FTP hostnames into HTTP links
|Reported by:||DavidAnderson||Owned by:|
Description (last modified by SergeyBiryukov)
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\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );
by removing the "ftp" case, hence:
$ret = preg_replace_callback( '#([\s>])((www)\.[\w\\x80-\\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 (14)
comment:2 @SergeyBiryukov — 3 years ago
- Component changed from General to Formatting
- Description modified (diff)
- Version changed from trunk to 2.0.4