Where is the code that filter web and email addresses into links?
This answer is for Drupal 7

You can see where the default filters are defined in /modules/filter/filter.module line 1147. There we see that _filter_url() (line 1358) is the function used to transform text into links.

You shouldn't modify this code directly. Instead you can implement hook_filter_info_alter() to change the process callback for url filter to your own function (you can copy _filter_url() and make the few changes you need)

function YOURMODULE_filter_info_alter(&amp;$info) {
  $info['filter_url']['process callback'] = 'YOURMODULE_filter_url';
}


Keep in mind that these changes will be reflected everywhere the URL Filter is used. If you need something not so "all inclusive", you can implement a new filter that you can apply to a seperate input format.