Opened 11 years ago
Last modified 10 years ago
#22946 closed defect (bug)
Default filter erroneously turns FTP hostnames into HTTP links — at Version 2
Reported by: | DavidAnderson | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.0.4 |
Component: | Formatting | Keywords: | close has-patch |
Focuses: | Cc: |
Description (last modified by )
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.
I don't know but isn't the idea to turn sites whose name starts with the string "ftp." into clickable links using the
ftp
protocol (e.g.ftp://ftp.example.com
)? Most browsers seem to handle this kind of thing just fine.