diff options
Diffstat (limited to '')
-rw-r--r-- | g10/build-packet.c | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/g10/build-packet.c b/g10/build-packet.c index 2ffc758e2..5c239b79e 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -891,12 +891,18 @@ build_attribute_subpkt(PKT_user_id *uid,byte type, struct notation * string_to_notation(const char *string,int is_utf8) { - const char *s,*i; - int saw_at=0,highbit=0; + const char *s; + int saw_at=0; struct notation *notation; notation=xmalloc_clear(sizeof(*notation)); + if(*string=='-') + { + notation->flags.ignore=1; + string++; + } + if(*string=='!') { notation->flags.critical=1; @@ -911,6 +917,10 @@ string_to_notation(const char *string,int is_utf8) if( *s=='@') saw_at++; + /* -notationname is legal without an = sign */ + if(!*s && notation->flags.ignore) + break; + if( !*s || !isascii (*s) || (!isgraph(*s) && !isspace(*s)) ) { log_error(_("a notation name must have only printable characters" @@ -936,26 +946,30 @@ string_to_notation(const char *string,int is_utf8) goto fail; } - i=s+1; - - /* we only support printable text - therefore we enforce the use of - only printable characters (an empty value is valid) */ - for(s++; *s ; s++ ) + if(*s) { - if ( !isascii (*s) ) - highbit=1; - else if (iscntrl(*s)) + const char *i=s+1; + int highbit=0; + + /* we only support printable text - therefore we enforce the use + of only printable characters (an empty value is valid) */ + for(s++; *s ; s++ ) { - log_error(_("a notation value must not use any" - " control characters\n")); - goto fail; + if ( !isascii (*s) ) + highbit=1; + else if (iscntrl(*s)) + { + log_error(_("a notation value must not use any" + " control characters\n")); + goto fail; + } } - } - if(!highbit || is_utf8) - notation->value=xstrdup(i); - else - notation->value=native_to_utf8(i); + if(!highbit || is_utf8) + notation->value=xstrdup(i); + else + notation->value=native_to_utf8(i); + } return notation; |