From 7b810b57f3197e9a75ec4ed25a8654aaf2ffd9cd Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 19 Apr 2017 16:40:20 +0200 Subject: [PATCH] Adopt taglist server side accordingly regarding domainOptional attribute --- api/src/Etemplate/Widget/Taglist.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/src/Etemplate/Widget/Taglist.php b/api/src/Etemplate/Widget/Taglist.php index b1d788e636..efb0b0343d 100644 --- a/api/src/Etemplate/Widget/Taglist.php +++ b/api/src/Etemplate/Widget/Taglist.php @@ -24,6 +24,14 @@ use mail_compose; */ class Taglist extends Etemplate\Widget { + + /** + * Regexp for validating email alias considering domain part be optional + * this should be used regarding the domainOptional attribute defined in + * taglist-email. + */ + const EMAIL_PREG_NO_DOMAIN = "/^(([^\042',<][^,<]+|\042[^\042]+\042|\'[^\']+\'|)\s?<)?[^\x01-\x20()<>@,;:\042\[\]]+(@([a-z0-9ÄÖÜäöüß](|[a-z0-9ÄÖÜäöüß_-]*[a-z0-9ÄÖÜäöüß])\.)+[a-z]{2,})?>?$/iu"; + /** * Constructor * @@ -131,6 +139,7 @@ class Taglist extends Etemplate\Widget } } else if($this->type == 'taglist-email' && !preg_match(Url::EMAIL_PREG, $val) && + !($this->attrs['domainOptional'] && preg_match (Taglist::EMAIL_PREG_NO_DOMAIN, $val)) && // Allow merge placeholders. Might be a better way to do this though. !preg_match('/{{.+}}|\$\$.+\$\$/',$val) )