The problems occurs when passing # and & in links to the Drupal link system. ‘#’ is heavily used in web to add 'anchor tag', and Drupal is not an exception; for comments, it depends on that. Further, external links may possibly include & and # which will be rendered incorrectly, or rather in unexpected way by Drupals link system.
Before going to deep discussion I will explain, the parts of the url:
for a url - http://www.domain.com/text/sample.html:8080
- scheme - e.g. http:// - (the protocol suit used)
- host – eg www.domain.com
- port – eg 8080 - which would follow the link by a colon
- path – eg text/sample.html - the total url part to the target from the host
- query - after the question mark ?
- fragment - after the hashmark # - eg: #comment-4 - for a url http://drupal.org/node/5#comment-4
However, users might have noticed that it renders the links correctly if it typed directly in the document. So the problem becomes only developers’ nightmare. Therefore, I would like to explain, how a link rendered as text in a page would be converted to a link. URL filter is doing this job.
function _filter_url($text, $format) , defined in filter.module, is doing the rendering. If we look at how it is done,
<?php
// Match absolute URLs.