aboutsummaryrefslogtreecommitdiffstats
path: root/g10/misc.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g10/misc.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 88b7b2bb1..14848eed2 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -1088,6 +1088,20 @@ has_invalid_email_chars (const char *s)
}
+/* Check whether NAME represents a valid mailbox according to
+ RFC822. Returns true if so. */
+int
+is_valid_mailbox (const char *name)
+{
+ return !( !name
+ || !*name
+ || has_invalid_email_chars (name)
+ || string_count_chr (name,'@') != 1
+ || *name == '@'
+ || name[strlen(name)-1] == '@'
+ || name[strlen(name)-1] == '.'
+ || strstr (name, "..") );
+}
/* This is a helper function to load a Windows function from either of