From 47c8a325f523260e0c96097335039deaf4c169f8 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Fri, 29 Mar 2002 16:52:07 +0000 Subject: [PATCH] If a delimiter is used, then quote the backslash character as well. Problem noted by Rainer Perske. --- util/ChangeLog | 6 ++++++ util/miscutil.c | 9 ++++++--- util/strgutil.c | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/util/ChangeLog b/util/ChangeLog index 375002a85..f6040ef5c 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,9 @@ +2002-03-29 David Shaw + + * 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 * http.c (write_server): Convert integer to a HANDLE for W32. diff --git a/util/miscutil.c b/util/miscutil.c index 3bff721c1..d6a10cb19 100644 --- a/util/miscutil.c +++ b/util/miscutil.c @@ -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'; diff --git a/util/strgutil.c b/util/strgutil.c index 7b72bbbe3..c4fafe562 100644 --- a/util/strgutil.c +++ b/util/strgutil.c @@ -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++ = '\\';