Hello.

I use the Module for a Linklist at a German University. Some of the Groups I try to link to do not have a Website. So I want to link there Mail Adresses.

Putting "mailto:somemailadress@web.de" works as expected, but this is not the correct Mail Adress.

"mailto:some-mail.adress-uni@web.de" does not work ("Not a valid URL."), but this is the Mail Adress. Is there some easy way to go around this or is work on the Code needed for this?

Thanks for the Module and your help in advance.
JThan

Comments

JThan’s picture

Category: support » bug

Hello.

I think this is a bug because valid Mail Adresses are rejected.

I do not know much about php and RegEx but i tried to figure it out. I did not get somewhere really, but I will describe what I think.Maybe it helps, maybe it's just confusing. Here it is:

If I give this regEx into a Validator in the web (e.g. http://www.perfectweb.com/resources/preg_match.php )

'[a-zA-Z0-9_\-\.\+\^!#\$%&*+\/\=\?\`\|\{\}~\'\[\]]+'

and give it this text: 'some-mail.adress-uni' it will work.

So I think the problem is not the regEx.

As I understand, this one should be true for mail and give back the Mail-Adress:

  if (in_array('mailto', $allowed_protocols) && preg_match($email_pattern, $text)) {
    return LINK_EMAIL;

But it seems to fail. Why?

I do not know.

This is the $email_pattern

$email_pattern = '/^mailto:' . $user . '@' . '(' . $domain . '|' . $ipv4 .'|'. $ipv6 . '|localhost)' . $query . '$/';

It should validate: 'mailto:some-mail.adress-uni@web.de' but it looks liek it does not. It validates 'mailto:somemailadress@web.de' but as soon as I enter '.' or '-' it says: 'Not a valid URL.'

I can not understand why.

Moonshine’s picture

I think that's an error in:

$email_pattern = '/^mailto:' . $user . '@' . '(' . $domain . '|' . $ipv4 .'|'. $ipv6 . '|localhost)' . $query . '$/';

With that, I believe that $query pattern has to be matched... you may want to try this:

$email_pattern = '/^mailto:' . $user . '@' . '(' . $domain . '|' . $ipv4 .'|'. $ipv6 . '|localhost)' . $query . '?' . '$/';

Maybe that will help ?

JThan’s picture

Status: Active » Needs review

Hello.

Works great!

Thank you! Can someone put this in the code?

I hope I put this to the correct status now, if not, please change (I am new here, so please forgive and tell me if I did something wrong).

JThan

quicksketch’s picture

Status: Needs review » Fixed

Thanks again Moonshine. I've committed the change to both Drupal 5 and 6 versions.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.