[wp-trac] [WordPress Trac] #23048: make_clickable should not add http:// to ftp. hostnames by default (ftp:// is a better default)

WordPress Trac noreply at wordpress.org
Sat Dec 22 17:14:17 UTC 2012


#23048: make_clickable should not add http:// to ftp. hostnames by default (ftp://
is a better default)
-----------------------------+--------------------------
 Reporter:  DavidAnderson    |       Type:  defect (bug)
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Formatting
  Version:                   |   Severity:  normal
 Keywords:                   |
-----------------------------+--------------------------
 make_clickable in wp-includes/formatting.php is a default filter.

 One of its activities is to detect this regex, and to call
 _make_web_ftp_clickable_cb on it:

 {{{
 ([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)
 }}}


 _make_web_ftp_clickable_cb then adds an <a href> tag, and pre-pends '
 'http://'.

 That seems quite wrong, as a default, for hostnames beginning with "ftp.".
 It bit me; I sent out an email with something like "FTP server:
 ftp.example.com" in it. This went through WP Better Emails, and ended up
 via this filter as 'Host: <a
 href="http://ftp.example.com">http://ftp.example.com</a>' - i.e. ended up
 confusingly wrong.

 I'm not sure that making links clickable by default is a good idea. But
 regardless of that, it's certainly wrong to *by default* change ftp.
 hostnames into http:// links, instead of into ftp:// links.

 Therefore the third line of the function _make_web_ftp_clickable_cb in wp-
 includes/formatting.php should be changed from:


 {{{
 $dest = 'http://' . $dest;
 }}}


 to:


 {{{
 $dest = ('ftp.' == substr($dest,0,4)) ? "ftp://" . $dest : "http://" .
 $dest;
 }}}

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


More information about the wp-trac mailing list