diff options
author | Werner Koch <[email protected]> | 2015-02-24 16:43:57 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2015-02-24 16:46:22 +0000 |
commit | 93fa3d5c1760f3fee5412fb29d58fbd60db16ea9 (patch) | |
tree | b89b401ea5231a9300aca6a9f299d693c36923bd /g10/misc.c | |
parent | common: Add another test case to zb32.c (diff) | |
download | gnupg-93fa3d5c1760f3fee5412fb29d58fbd60db16ea9.tar.gz gnupg-93fa3d5c1760f3fee5412fb29d58fbd60db16ea9.zip |
gpg: Add function to extract the mailbox.
* g10/misc.c (has_invalid_email_chars, is_valid_mailbox)
(is_valid_user_id): Move to ...
* g10/mailbox.c: new file.
(string_has_ctrl_or_space, has_dotdot_after_at): New.
(has_invalid_email_chars): New.
* g10/t-mailbox.c: New.
* g10/Makefile.am (module_tests): Add t-mailbox.
(t_mailbox_SOURCES, t_mailbox_LDADD): New.
--
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/misc.c')
-rw-r--r-- | g10/misc.c | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/g10/misc.c b/g10/misc.c index 276ff0a1a..4cff2dc88 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -70,18 +70,6 @@ #include <assert.h> -static int -string_count_chr (const char *string, int c) -{ - int count; - - for (count=0; *string; string++ ) - if ( *string == c ) - count++; - return count; -} - - #ifdef ENABLE_SELINUX_HACKS /* A object and a global variable to keep track of files marked as @@ -1464,69 +1452,6 @@ parse_options(char *str,unsigned int *options, } -/* Check whether the string has characters not valid in an RFC-822 - address. To cope with OpenPGP we ignore non-ascii characters - so that for example umlauts are legal in an email address. An - OpenPGP user ID must be utf-8 encoded but there is no strict - requirement for RFC-822. Thus to avoid IDNA encoding we put the - address verbatim as utf-8 into the user ID under the assumption - that mail programs handle IDNA at a lower level and take OpenPGP - user IDs as utf-8. Note that we can't do an utf-8 encoding - checking here because in keygen.c this function is called with the - native encoding and native to utf-8 encoding is only done later. */ -int -has_invalid_email_chars (const char *s) -{ - int at_seen=0; - const char *valid_chars= - "01234567890_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - for ( ; *s; s++ ) - { - if ( (*s & 0x80) ) - continue; /* We only care about ASCII. */ - if ( *s == '@' ) - at_seen=1; - else if ( !at_seen && !(strchr (valid_chars, *s) - || strchr ("!#$%&'*+/=?^`{|}~", *s))) - return 1; - else if ( at_seen && !strchr( valid_chars, *s ) ) - return 1; - } - return 0; -} - - -/* 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, "..") ); -} - - -/* Check whether UID is a valid standard user id of the form - "Heinrich Heine <[email protected]>" - and return true if this is the case. */ -int -is_valid_user_id (const char *uid) -{ - if (!uid || !*uid) - return 0; - - return 1; -} - - - /* Similar to access(2), but uses PATH to find the file. */ int path_access(const char *file,int mode) |