summaryrefslogtreecommitdiff
path: root/common/src/email-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/email-utils.c')
-rwxr-xr-xcommon/src/email-utils.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/common/src/email-utils.c b/common/src/email-utils.c
index 05a3902..741a5d1 100755
--- a/common/src/email-utils.c
+++ b/common/src/email-utils.c
@@ -294,6 +294,43 @@ guint64 email_get_file_size(const gchar *path)
return size;
}
+#define EMAIL_ACCOUNT_RGEX "([a-z0-9!#$%&'*+/=?^_`{|}~-]+[.])*[a-z0-9!#$%&'*+/=?^_`{|}~-]+"
+#define EMAIL_DOMAIN_RGEX "([a-z0-9!#$%&'*+/=?^_`{|}~-]+[.])+[a-z0-9!#$%&'*+/=?^_`{|}~-]+"
+#define EMAIL_ADDR_RGEX EMAIL_ACCOUNT_RGEX"@"EMAIL_DOMAIN_RGEX
+
+gboolean email_get_address_validation(const char *address)
+{
+ debug_log("");
+ /* this following code verfies the email alias string using reg. exp. */
+ regex_t alias_list_regex;
+ int ret = FALSE;
+
+ if (regcomp(&alias_list_regex, EMAIL_ADDR_RGEX, REG_ICASE | REG_EXTENDED)) {
+ debug_log("email alias regex unrecognized");
+ return FALSE;
+ }
+
+ int nsub = alias_list_regex.re_nsub + 1; /* should be the number of parenthesized subexpressions (+1) */
+ regmatch_t pmatch[nsub];
+ memset(pmatch, 0, sizeof(regmatch_t) * nsub);
+
+ if (regexec(&alias_list_regex, address, nsub, pmatch, 0) == REG_NOMATCH)
+ debug_log("failed : [%s]", address);
+ else {
+ debug_log("success : [%s]", address);
+
+ /*
+ * remove sub-string match
+ */
+ if ((int)(pmatch[0].rm_eo - pmatch[0].rm_so) == strlen(address))
+ ret = TRUE;
+ }
+
+ regfree(&alias_list_regex);
+
+ return ret;
+}
+
char *email_get_date_text(const char *locale, char *skeleton, void *time)
{
debug_log("");