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

RobRoy’s picture

Assigned: Unassigned » RobRoy
Status: Active » Fixed

That 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!

RobRoy’s picture

For 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);

brevity’s picture

Status: Fixed » Active

Thanks 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!

RobRoy’s picture

Status: Active » Closed (fixed)

We've changed the functionality of this module, so you now link to internal://node/5 or whatever to enact this filter.