[wp-trac] [WordPress Trac] #22946: Default filter erroneously turns FTP hostnames into HTTP links

WordPress Trac noreply at wordpress.org
Fri Dec 14 20:01:52 UTC 2012


#22946: Default filter erroneously turns FTP hostnames into HTTP links
-----------------------------+--------------------------
 Reporter:  DavidAnderson    |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  General
  Version:  trunk            |   Severity:  normal
 Keywords:                   |
-----------------------------+--------------------------
 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.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22946>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list