--- parser3/src/main/untaint.C 2011/02/18 06:03:53 1.162 +++ parser3/src/main/untaint.C 2015/04/08 18:08:53 1.166 @@ -1,11 +1,11 @@ /** @file Parser: String class part: untaint mechanizm. - Copyright(c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_UNTAINT_C="$Date: 2011/02/18 06:03:53 $"; +volatile const char * IDENT_UNTAINT_C="$Id: untaint.C,v 1.166 2015/04/08 18:08:53 moko Exp $"; #include "pa_string.h" @@ -61,10 +61,9 @@ extern "C" { // author forgot to do that #define _default CORD_ec_append(info->result, c) #define encode(need_encode_func, prefix, otherwise) \ if(need_encode_func(c)) { \ - static const char* hex="0123456789ABCDEF"; \ CORD_ec_append(info->result, prefix); \ - CORD_ec_append(info->result, hex[((unsigned char)c)/0x10]); \ - CORD_ec_append(info->result, hex[((unsigned char)c)%0x10]); \ + CORD_ec_append(info->result, hex_digits[((unsigned char)c) >> 4]); \ + CORD_ec_append(info->result, hex_digits[((unsigned char)c) & 0x0F]); \ } else \ CORD_ec_append(info->result, otherwise); #define to_char(c) { CORD_ec_append(info->result, c); whitespace=false; } @@ -74,7 +73,7 @@ inline bool need_file_encode(unsigned ch // russian letters and space ENABLED // encoding only these... return strchr( - "*?'\"<>|" + "*?\"<>|" #ifndef WIN32 ":\\" #endif @@ -393,8 +392,8 @@ int cstr_to_string_body_block(String::La } //RFC + An 'encoded-word' MUST NOT appear in any portion of an 'addr-spec'. if(!email && ( - !to_quoted_printable && (c & 0x80) // starting quote-printable-encoding on first 8bit char - || to_quoted_printable && !mail_header_char_valid_within_Qencoded(c) + ( !to_quoted_printable && (c & 0x80) ) // starting quote-printable-encoding on first 8bit char + || ( to_quoted_printable && !mail_header_char_valid_within_Qencoded(c) ) )) { if(!to_quoted_printable) { to_string("=?"); @@ -504,7 +503,15 @@ int cstr_to_string_body_block(String::La case '\r': to_string("\\r"); break; case '\b': to_string("\\b"); break; case '\f': to_string("\\f"); break; - default : _default; break; + default: + if((unsigned char)c < 0x20){ + to_string("\\u00"); + to_char(hex_digits[((unsigned char)c) >> 4]); + to_char(hex_digits[((unsigned char)c) & 0x0F]); + } else { + _default; + } + break; }); } else { const char *fragment_str=info->body->mid(info->fragment_begin, fragment_length).cstr();