mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-14 21:47:19 +02:00
* build-packet.c (string_to_notation): Add ability to indicate a notation
to be deleted with a '-' prefix. * keyedit.c (menu_set_notation): Use it here to allow deleting a notation marked with '-'. This works with either "-notation" or "-notation=value".
This commit is contained in:
parent
a917165bef
commit
e914311608
3 changed files with 87 additions and 41 deletions
|
@ -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))
|
||||
{
|
||||
log_error(_("a notation value must not use any"
|
||||
" control characters\n"));
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
const char *i=s+1;
|
||||
int highbit=0;
|
||||
|
||||
if(!highbit || is_utf8)
|
||||
notation->value=xstrdup(i);
|
||||
else
|
||||
notation->value=native_to_utf8(i);
|
||||
/* we only support printable text - therefore we enforce the use
|
||||
of only printable characters (an empty value is valid) */
|
||||
for(s++; *s ; s++ )
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
return notation;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue