0

I think recently some global changes have been going on to the e-mail addressing protocols. Now we have a new set of characters allowed in email addresses.

For example in Spain we have character 'ñ' and this is now allowed in email address, for example mañoso@example.com

The problem I have with SugarCE (version 6.5.9) is that there is a validation in the contacts email1 field that doesn't allow to store this character and when saving the form it gives "invalid value" error.

Does anyone know where in the source code is this validation function so I can modify it?

Thanks!

--update--

found something about validation like Chad said in include/SugarEmailAddress/SugarEmailAddress.php but can't get my ñ character to validate.

Please help me modify this code according to requirements:

//bug 40068, According to rules in page 6 of apps.ietf.org/rfc/rfc3696.html#sec-3,
//allowed special characters ! # $ % & ' * + - / = ? ^ _ ` . { | } ~ in local part 
var $regex = "/^(?:['\.\-\+&#!\$\*=\?\^_`\{\}~\/\w]+)@(?:(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|\w+(?:[\.-]*\w+)*(?:\.[\w-]{2,})+)\$/";
Jack Casas
  • 914
  • 18
  • 37

1 Answers1

0

There is also a javascript validation.

The PHP regex is defined twice - which seems to be quite normal at SugarCRM:

SugarEmailAddress/SugarEmailAddress.php
include/SugarEmailAddress/SugarEmailAddress.php

I have replaced the regex with this:

var $regex = '/^((?!\s).)*@.*?\.[A-Z]{2,6}$/i';

Which is not perfect, but works well enough for me. So we can store email addresses via REST API at least.

The javascript validation is also present in two locations:

include/javascript/sugar_3.js
jssource/src_files/include/javascript/sugar_3.js

I've replaced both regex there with the above one:

OLD 1 : /^\s*[\w.%+\-&'#!\$\*=\?\^_`\{\}~\/]+@([A-Z0-9-]+\.)*[A-Z0-9-]+\.[\w-]{2,}\s*$/i
OLD 2 : /^.*<[A-Z0-9._%+\-&'#!\$\*=\?\^_`\{\}~]+?@([A-Z0-9-]+\.)*[A-Z0-9-]+\.[\w-]{2,}>\s*$/i

Now we can store IDN email addresses and addresses which have UTF-8 chars in local parts.

That's not a perfect solution, but it works for me. Maybe it does work for you too.