URLs beginning with 'http://' and the like should not be rewritten -- maybe this is only the case in my environment with the i18n.module?
For a start I changed line 44 to:
return preg_replace_callback('/(<a[^>]+href=(["\']?))([^"\'>http]+)(\\2)/i', '_urlaliasfilter_callback', $node->$field);
Cheers. Great module!
Comments
Comment #1
RobRoy commentedThat preg expression is a bit faulty as [^http] doesn't allow any url with h, t, or p in them. You bring up a good point about not checking external links and I've committed a fix to HEAD.
Thanks!
Comment #2
RobRoy commentedFor the sake of learning, here is the new preg expression that doesn't match http/https/ftp and allows for an optional index.php?q=, ?q= with an optional slash. It could probably still use some work, but it seems okay now.
return preg_replace_callback('@(]+href=(["\']?))(?!.*?((http|https|ftp)://))(index.php\?q=|\?q=)?[/]?([^\\2>]+)(\\2)@is', '_urlaliasfilter_callback', $node->$field);
Comment #3
brevity commentedThanks for the quick update!
mailto:-links should be included, too, I reckon... Another problem in my environment: As I'm using the i18n.module, the url-function squeezes two language-denoting characters into the resulting URL, e.g. ...domain.org/en/path/file -- this kills links to downloadable files, though, as those are only available without the language bit. ...could use url rewrites in .htaccess probably, but maybe a solution to leave out .pdf/.zip-files from urlaliasfiltering would be a better idea? Cheers!Comment #4
RobRoy commentedWe've changed the functionality of this module, so you now link to internal://node/5 or whatever to enact this filter.