1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01: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>
* 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 )
{
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);
if( *p == '\n' )
putc('n', fp);
@ -246,7 +247,8 @@ make_printable_string( const byte *p, size_t n, int delim )
/* first count length */
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'
|| *p=='\v' || *p=='\b' || !*p )
buflen += 2;
@ -261,7 +263,8 @@ make_printable_string( const byte *p, size_t n, int delim )
/* and now make the string */
d = buffer = m_alloc( buflen );
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++ = '\\';
if( *p == '\n' )
*d++ = 'n';

View File

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