mirror of
git://git.gnupg.org/gnupg.git
synced 2025-05-24 16:43:28 +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
@ -1,3 +1,12 @@
|
|||||||
|
2006-03-09 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* 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".
|
||||||
|
|
||||||
2006-03-08 David Shaw <dshaw@jabberwocky.com>
|
2006-03-08 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* keyedit.c (menu_set_notation): New function to set notations on
|
* keyedit.c (menu_set_notation): New function to set notations on
|
||||||
|
@ -891,12 +891,18 @@ build_attribute_subpkt(PKT_user_id *uid,byte type,
|
|||||||
struct notation *
|
struct notation *
|
||||||
string_to_notation(const char *string,int is_utf8)
|
string_to_notation(const char *string,int is_utf8)
|
||||||
{
|
{
|
||||||
const char *s,*i;
|
const char *s;
|
||||||
int saw_at=0,highbit=0;
|
int saw_at=0;
|
||||||
struct notation *notation;
|
struct notation *notation;
|
||||||
|
|
||||||
notation=xmalloc_clear(sizeof(*notation));
|
notation=xmalloc_clear(sizeof(*notation));
|
||||||
|
|
||||||
|
if(*string=='-')
|
||||||
|
{
|
||||||
|
notation->flags.ignore=1;
|
||||||
|
string++;
|
||||||
|
}
|
||||||
|
|
||||||
if(*string=='!')
|
if(*string=='!')
|
||||||
{
|
{
|
||||||
notation->flags.critical=1;
|
notation->flags.critical=1;
|
||||||
@ -911,6 +917,10 @@ string_to_notation(const char *string,int is_utf8)
|
|||||||
if( *s=='@')
|
if( *s=='@')
|
||||||
saw_at++;
|
saw_at++;
|
||||||
|
|
||||||
|
/* -notationname is legal without an = sign */
|
||||||
|
if(!*s && notation->flags.ignore)
|
||||||
|
break;
|
||||||
|
|
||||||
if( !*s || !isascii (*s) || (!isgraph(*s) && !isspace(*s)) )
|
if( !*s || !isascii (*s) || (!isgraph(*s) && !isspace(*s)) )
|
||||||
{
|
{
|
||||||
log_error(_("a notation name must have only printable characters"
|
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;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
i=s+1;
|
if(*s)
|
||||||
|
|
||||||
/* 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) )
|
const char *i=s+1;
|
||||||
highbit=1;
|
int highbit=0;
|
||||||
else if (iscntrl(*s))
|
|
||||||
{
|
|
||||||
log_error(_("a notation value must not use any"
|
|
||||||
" control characters\n"));
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!highbit || is_utf8)
|
/* we only support printable text - therefore we enforce the use
|
||||||
notation->value=xstrdup(i);
|
of only printable characters (an empty value is valid) */
|
||||||
else
|
for(s++; *s ; s++ )
|
||||||
notation->value=native_to_utf8(i);
|
{
|
||||||
|
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;
|
return notation;
|
||||||
|
|
||||||
|
@ -4178,7 +4178,8 @@ menu_set_notation(const char *string,KBNODE pub_keyblock,KBNODE sec_keyblock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ascii_strcasecmp(answer,"none")==0)
|
if(ascii_strcasecmp(answer,"none")==0
|
||||||
|
|| ascii_strcasecmp(answer,"-")==0)
|
||||||
notation=NULL; /* delete them all */
|
notation=NULL; /* delete them all */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -4238,7 +4239,7 @@ menu_set_notation(const char *string,KBNODE pub_keyblock,KBNODE sec_keyblock)
|
|||||||
{
|
{
|
||||||
tty_printf("Current notations for user ID \"%s\":\n",
|
tty_printf("Current notations for user ID \"%s\":\n",
|
||||||
user);
|
user);
|
||||||
tty_print_notations(-10,sig);
|
tty_print_notations(-9,sig);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -4253,39 +4254,61 @@ menu_set_notation(const char *string,KBNODE pub_keyblock,KBNODE sec_keyblock)
|
|||||||
|
|
||||||
if(notation)
|
if(notation)
|
||||||
{
|
{
|
||||||
struct notation *n,*list=sig_to_notation(sig);
|
struct notation *n;
|
||||||
notation->next=list;
|
int deleting=0;
|
||||||
|
|
||||||
for(n=list;n;n=n->next)
|
notation->next=sig_to_notation(sig);
|
||||||
|
|
||||||
|
for(n=notation->next;n;n=n->next)
|
||||||
if(strcmp(n->name,notation->name)==0)
|
if(strcmp(n->name,notation->name)==0)
|
||||||
{
|
{
|
||||||
if(strcmp(n->value,notation->value)==0)
|
if(notation->value)
|
||||||
{
|
{
|
||||||
/* Adding the same notation twice, so
|
if(strcmp(n->value,notation->value)==0)
|
||||||
don't add it at all. */
|
{
|
||||||
skip=1;
|
if(notation->flags.ignore)
|
||||||
tty_printf("Skipping notation: %s=%s\n",
|
{
|
||||||
notation->name,notation->value);
|
/* Value match with a delete
|
||||||
notation->flags.ignore=1;
|
flag. */
|
||||||
break;
|
n->flags.ignore=1;
|
||||||
|
deleting=1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Adding the same notation
|
||||||
|
twice, so don't add it at
|
||||||
|
all. */
|
||||||
|
skip=1;
|
||||||
|
tty_printf("Skipping notation:"
|
||||||
|
" %s=%s\n",
|
||||||
|
notation->name,
|
||||||
|
notation->value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(notation->value[0]=='\0')
|
else
|
||||||
{
|
{
|
||||||
/* No value, so we don't replace this
|
/* No value, so it means delete. */
|
||||||
notation with anything. */
|
|
||||||
n->flags.ignore=1;
|
n->flags.ignore=1;
|
||||||
notation->flags.ignore=1;
|
deleting=1;
|
||||||
addonly=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(n->flags.ignore)
|
if(n->flags.ignore)
|
||||||
tty_printf("Removing notation: %s=%s\n",
|
{
|
||||||
n->name,n->value);
|
tty_printf("Removing notation: %s=%s\n",
|
||||||
|
n->name,n->value);
|
||||||
|
addonly=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!notation->flags.ignore)
|
if(!notation->flags.ignore && !skip)
|
||||||
tty_printf("Adding notation: %s=%s\n",
|
tty_printf("Adding notation: %s=%s\n",
|
||||||
notation->name,notation->value);
|
notation->name,notation->value);
|
||||||
|
|
||||||
|
/* We tried to delete, but had no matches */
|
||||||
|
if(notation->flags.ignore && !deleting)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user