1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-07-04 03:08:57 +02:00

If a delimiter is used, then quote the backslash character as well.

Problem noted by Rainer Perske.
This commit is contained in:
David Shaw 2002-03-29 16:52:07 +00:00
parent d56fb26c55
commit 47c8a325f5
3 changed files with 14 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2002-03-29 David Shaw <dshaw@jabberwocky.com>
* strgutil.c (print_string, utf8_to_native): If a delimiter is
used, then quote the backslash character as well. Problem noted
by Rainer Perske.
2002-02-28 Timo Schulz <ts@winpt.org> 2002-02-28 Timo Schulz <ts@winpt.org>
* http.c (write_server): Convert integer to a HANDLE for W32. * http.c (write_server): Convert integer to a HANDLE for W32.

View File

@ -182,7 +182,8 @@ void
print_string( FILE *fp, const byte *p, size_t n, int delim ) print_string( FILE *fp, const byte *p, size_t n, int delim )
{ {
for( ; n; n--, p++ ) for( ; n; n--, p++ )
if( *p < 0x20 || (*p >= 0x7f && *p < 0xa0) || *p == delim ) { if( *p < 0x20 || (*p >= 0x7f && *p < 0xa0) || *p == delim ||
(delim && *p=='\\')) {
putc('\\', fp); putc('\\', fp);
if( *p == '\n' ) if( *p == '\n' )
putc('n', fp); putc('n', fp);
@ -246,7 +247,8 @@ make_printable_string( const byte *p, size_t n, int delim )
/* first count length */ /* first count length */
for(save_n = n, save_p = p, buflen=1 ; n; n--, p++ ) { for(save_n = n, save_p = p, buflen=1 ; n; n--, p++ ) {
if( *p < 0x20 || (*p >= 0x7f && *p < 0xa0) || *p == delim ) { if( *p < 0x20 || (*p >= 0x7f && *p < 0xa0) || *p == delim ||
(delim && *p=='\\')) {
if( *p=='\n' || *p=='\r' || *p=='\f' if( *p=='\n' || *p=='\r' || *p=='\f'
|| *p=='\v' || *p=='\b' || !*p ) || *p=='\v' || *p=='\b' || !*p )
buflen += 2; buflen += 2;
@ -261,7 +263,8 @@ make_printable_string( const byte *p, size_t n, int delim )
/* and now make the string */ /* and now make the string */
d = buffer = m_alloc( buflen ); d = buffer = m_alloc( buflen );
for( ; n; n--, p++ ) { for( ; n; n--, p++ ) {
if( *p < 0x20 || (*p >= 0x7f && *p < 0xa0) || *p == delim ) { if( *p < 0x20 || (*p >= 0x7f && *p < 0xa0) || *p == delim ||
(delim && *p=='\\')) {
*d++ = '\\'; *d++ = '\\';
if( *p == '\n' ) if( *p == '\n' )
*d++ = 'n'; *d++ = 'n';

View File

@ -476,7 +476,8 @@ utf8_to_native( const char *string, size_t length, int delim )
} }
if( !nleft ) { if( !nleft ) {
if( !(*s & 0x80) ) { /* plain ascii */ if( !(*s & 0x80) ) { /* plain ascii */
if( *s < 0x20 || *s == 0x7f || *s == delim) { if( *s < 0x20 || *s == 0x7f || *s == delim ||
(delim && *s=='\\')) {
n++; n++;
if( p ) if( p )
*p++ = '\\'; *p++ = '\\';