mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-01 16:33:02 +01:00
* filter.h, armor.c (armor_filter): Use the eol string from the armor
filter context instead of hardcoding '\n' or '\r\n'. If no eol string is provided, default to '\n' or '\r\n' as appropriate. (is_armor_header): Trim tabs in armor header lines as well. * keyserver.c (keyserver_spawn): Use it here to force '\n' line endings since the keyserver output file gets a LF->CRLF expansion on win32.
This commit is contained in:
parent
9dc1bcc4ea
commit
f464dcef59
@ -1,3 +1,14 @@
|
|||||||
|
2005-01-06 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* filter.h, armor.c (armor_filter): Use the eol string from the
|
||||||
|
armor filter context instead of hardcoding '\n' or '\r\n'. If no
|
||||||
|
eol string is provided, default to '\n' or '\r\n' as appropriate.
|
||||||
|
(is_armor_header): Trim tabs in armor header lines as well.
|
||||||
|
|
||||||
|
* keyserver.c (keyserver_spawn): Use it here to force '\n' line
|
||||||
|
endings since the keyserver output file gets a LF->CRLF expansion
|
||||||
|
on win32.
|
||||||
|
|
||||||
2005-01-05 David Shaw <dshaw@jabberwocky.com>
|
2005-01-05 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* g10.c (main): Typo.
|
* g10.c (main): Typo.
|
||||||
|
67
g10/armor.c
67
g10/armor.c
@ -1,6 +1,6 @@
|
|||||||
/* armor.c - Armor flter
|
/* armor.c - Armor flter
|
||||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||||
* 2004 Free Software Foundation, Inc.
|
* 2005 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -38,12 +38,6 @@
|
|||||||
#include "status.h"
|
#include "status.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
#ifdef HAVE_DOSISH_SYSTEM
|
|
||||||
#define LF "\r\n"
|
|
||||||
#else
|
|
||||||
#define LF "\n"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAX_LINELEN 20000
|
#define MAX_LINELEN 20000
|
||||||
|
|
||||||
#define CRCINIT 0xB704CE
|
#define CRCINIT 0xB704CE
|
||||||
@ -119,7 +113,6 @@ static char *tail_strings[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
initialize(void)
|
initialize(void)
|
||||||
{
|
{
|
||||||
@ -306,7 +299,7 @@ is_armor_header( byte *line, unsigned len )
|
|||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
while(*p==' ' || *p=='\r' || *p=='\n')
|
while(*p==' ' || *p=='\r' || *p=='\n' || *p=='\t')
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
if( *p )
|
if( *p )
|
||||||
@ -984,10 +977,14 @@ armor_filter( void *opaque, int control,
|
|||||||
log_bug("afx->what=%d", afx->what);
|
log_bug("afx->what=%d", afx->what);
|
||||||
iobuf_writestr(a, "-----");
|
iobuf_writestr(a, "-----");
|
||||||
iobuf_writestr(a, head_strings[afx->what] );
|
iobuf_writestr(a, head_strings[afx->what] );
|
||||||
iobuf_writestr(a, "-----" LF );
|
iobuf_writestr(a, "-----" );
|
||||||
|
iobuf_writestr(a,afx->eol);
|
||||||
if( !opt.no_version )
|
if( !opt.no_version )
|
||||||
|
{
|
||||||
iobuf_writestr(a, "Version: GnuPG v" VERSION " ("
|
iobuf_writestr(a, "Version: GnuPG v" VERSION " ("
|
||||||
PRINTABLE_OS_NAME ")" LF );
|
PRINTABLE_OS_NAME ")" );
|
||||||
|
iobuf_writestr(a,afx->eol);
|
||||||
|
}
|
||||||
|
|
||||||
/* write the comment strings */
|
/* write the comment strings */
|
||||||
for(s=comment->d;comment;comment=comment->next,s=comment->d)
|
for(s=comment->d;comment;comment=comment->next,s=comment->d)
|
||||||
@ -1004,7 +1001,8 @@ armor_filter( void *opaque, int control,
|
|||||||
else
|
else
|
||||||
iobuf_put(a, *s );
|
iobuf_put(a, *s );
|
||||||
}
|
}
|
||||||
iobuf_writestr(a, LF );
|
|
||||||
|
iobuf_writestr(a,afx->eol);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( afx->hdrlines ) {
|
if ( afx->hdrlines ) {
|
||||||
@ -1016,7 +1014,8 @@ armor_filter( void *opaque, int control,
|
|||||||
iobuf_put(a, *s );
|
iobuf_put(a, *s );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iobuf_writestr(a, LF );
|
|
||||||
|
iobuf_writestr(a,afx->eol);
|
||||||
afx->status++;
|
afx->status++;
|
||||||
afx->idx = 0;
|
afx->idx = 0;
|
||||||
afx->idx2 = 0;
|
afx->idx2 = 0;
|
||||||
@ -1045,10 +1044,11 @@ armor_filter( void *opaque, int control,
|
|||||||
iobuf_put(a, c);
|
iobuf_put(a, c);
|
||||||
c = bintoasc[radbuf[2]&077];
|
c = bintoasc[radbuf[2]&077];
|
||||||
iobuf_put(a, c);
|
iobuf_put(a, c);
|
||||||
if( ++idx2 >= (64/4) ) { /* pgp doesn't like 72 here */
|
if( ++idx2 >= (64/4) )
|
||||||
iobuf_writestr(a, LF );
|
{ /* pgp doesn't like 72 here */
|
||||||
|
iobuf_writestr(a,afx->eol);
|
||||||
idx2=0;
|
idx2=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i=0; i < idx; i++ )
|
for(i=0; i < idx; i++ )
|
||||||
@ -1057,10 +1057,23 @@ armor_filter( void *opaque, int control,
|
|||||||
afx->idx2 = idx2;
|
afx->idx2 = idx2;
|
||||||
afx->crc = crc;
|
afx->crc = crc;
|
||||||
}
|
}
|
||||||
else if( control == IOBUFCTRL_INIT ) {
|
else if( control == IOBUFCTRL_INIT )
|
||||||
|
{
|
||||||
if( !is_initialized )
|
if( !is_initialized )
|
||||||
initialize();
|
initialize();
|
||||||
}
|
|
||||||
|
/* Figure out what we're using for line endings if the caller
|
||||||
|
didn't specify. */
|
||||||
|
if(afx->eol[0]==0)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_DOSISH_SYSTEM
|
||||||
|
afx->eol[0]='\r';
|
||||||
|
afx->eol[1]='\n';
|
||||||
|
#else
|
||||||
|
afx->eol[0]='\n';
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
else if( control == IOBUFCTRL_CANCEL ) {
|
else if( control == IOBUFCTRL_CANCEL ) {
|
||||||
afx->cancel = 1;
|
afx->cancel = 1;
|
||||||
}
|
}
|
||||||
@ -1089,14 +1102,15 @@ armor_filter( void *opaque, int control,
|
|||||||
iobuf_put(a, c);
|
iobuf_put(a, c);
|
||||||
iobuf_put(a, '=');
|
iobuf_put(a, '=');
|
||||||
}
|
}
|
||||||
if( ++idx2 >= (64/4) ) { /* pgp doesn't like 72 here */
|
if( ++idx2 >= (64/4) )
|
||||||
iobuf_writestr(a, LF );
|
{ /* pgp doesn't like 72 here */
|
||||||
|
iobuf_writestr(a,afx->eol);
|
||||||
idx2=0;
|
idx2=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* may need a linefeed */
|
/* may need a linefeed */
|
||||||
if( idx2 )
|
if( idx2 )
|
||||||
iobuf_writestr(a, LF );
|
iobuf_writestr(a,afx->eol);
|
||||||
/* write the CRC */
|
/* write the CRC */
|
||||||
iobuf_put(a, '=');
|
iobuf_put(a, '=');
|
||||||
radbuf[0] = crc >>16;
|
radbuf[0] = crc >>16;
|
||||||
@ -1110,13 +1124,14 @@ armor_filter( void *opaque, int control,
|
|||||||
iobuf_put(a, c);
|
iobuf_put(a, c);
|
||||||
c = bintoasc[radbuf[2]&077];
|
c = bintoasc[radbuf[2]&077];
|
||||||
iobuf_put(a, c);
|
iobuf_put(a, c);
|
||||||
iobuf_writestr(a, LF );
|
iobuf_writestr(a,afx->eol);
|
||||||
/* and the the trailer */
|
/* and the the trailer */
|
||||||
if( afx->what >= DIM(tail_strings) )
|
if( afx->what >= DIM(tail_strings) )
|
||||||
log_bug("afx->what=%d", afx->what);
|
log_bug("afx->what=%d", afx->what);
|
||||||
iobuf_writestr(a, "-----");
|
iobuf_writestr(a, "-----");
|
||||||
iobuf_writestr(a, tail_strings[afx->what] );
|
iobuf_writestr(a, tail_strings[afx->what] );
|
||||||
iobuf_writestr(a, "-----" LF );
|
iobuf_writestr(a, "-----" );
|
||||||
|
iobuf_writestr(a,afx->eol);
|
||||||
}
|
}
|
||||||
else if( !afx->any_data && !afx->inp_bypass ) {
|
else if( !afx->any_data && !afx->inp_bypass ) {
|
||||||
log_error(_("no valid OpenPGP data found.\n"));
|
log_error(_("no valid OpenPGP data found.\n"));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/* filter.h
|
/* filter.h
|
||||||
* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
* Copyright (C) 1998, 1999, 2000, 2001, 2003,
|
||||||
|
* 2005 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -48,6 +49,10 @@ typedef struct {
|
|||||||
int truncated; /* number of truncated lines */
|
int truncated; /* number of truncated lines */
|
||||||
int qp_detected;
|
int qp_detected;
|
||||||
int pgp2mode;
|
int pgp2mode;
|
||||||
|
byte eol[3]; /* The end of line characters as a
|
||||||
|
zero-terminated string. Defaults
|
||||||
|
(eol[0]=='\0') to whatever the local
|
||||||
|
platform uses. */
|
||||||
|
|
||||||
byte *buffer; /* malloced buffer */
|
byte *buffer; /* malloced buffer */
|
||||||
unsigned buffer_size; /* and size of this buffer */
|
unsigned buffer_size; /* and size of this buffer */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* keyserver.c - generic keyserver code
|
/* keyserver.c - generic keyserver code
|
||||||
* Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
* Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -966,6 +966,13 @@ keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc,
|
|||||||
|
|
||||||
memset(&afx,0,sizeof(afx));
|
memset(&afx,0,sizeof(afx));
|
||||||
afx.what=1;
|
afx.what=1;
|
||||||
|
/* Tell the armor filter to use Unix-style \n line
|
||||||
|
endings, since we're going to fprintf this to a file
|
||||||
|
that (on Win32) is open in text mode. The win32 stdio
|
||||||
|
will transform the \n to \r\n and we'll end up with the
|
||||||
|
proper line endings on win32. This is a no-op on
|
||||||
|
Unix. */
|
||||||
|
afx.eol[0]='\n';
|
||||||
iobuf_push_filter(buffer,armor_filter,&afx);
|
iobuf_push_filter(buffer,armor_filter,&afx);
|
||||||
|
|
||||||
/* TODO: Remove Comment: lines from keys exported this
|
/* TODO: Remove Comment: lines from keys exported this
|
||||||
|
Loading…
x
Reference in New Issue
Block a user