--- parser3/src/main/untaint.C 2009/08/21 08:38:55 1.151 +++ parser3/src/main/untaint.C 2009/09/10 12:31:43 1.154 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_UNTAINT_C="$Date: 2009/08/21 08:38:55 $"; +static const char * const IDENT_UNTAINT_C="$Date: 2009/09/10 12:31:43 $"; #include "pa_string.h" @@ -82,7 +82,7 @@ inline bool need_file_encode(unsigned ch } inline bool need_uri_encode(unsigned char c){ - if((c>='0') &&(c<='9') ||(c>='A') &&(c<='Z') ||(c>='a') &&(c<='z')) + if((c>='0') && (c<='9') || (c>='A') && (c<='Z') || (c>='a') && (c<='z')) return false; return !strchr("_-./", c); @@ -108,34 +108,35 @@ inline bool need_parser_code_escape(unsi /* HTTP-header = field-name ":" [ field-value ] CRLF - field-name = token - field-value = *( field-content | LWS ) +field-name = token +field-value = *( field-content | LWS ) - field-content = - -word = token | quoted-string - token = 1* +word = token | quoted-string +quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) +qdtext = > +quoted-pair = "\" CHAR - +OCTET = +CHAR = tspecials = "(" | ")" | "<" | ">" | "@" - | "," | ";" | ":" | "\" | <"> - | "/" | "[" | "]" | "?" | "=" - | "{" | "}" | SP | HT + | "," | ";" | ":" | "\" | <"> + | "/" | "[" | "]" | "?" | "=" + | "{" | "}" | SP | HT SP = HT = LWS = [CRLF] 1*( SP | HT ) -TEXT = +TEXT = +CTL = -quoted-pair = "\" CHAR if(strchr("()<>@,;:\\\"/[]?={} \t", *ptr)) */ @@ -348,14 +349,8 @@ int cstr_to_string_body_block(String::La case String::L_FILE_SPEC: // tainted, untaint language: file [name] { - bool is1251=(info->charsets && info->charsets->source().NAME()=="WINDOWS-1251"); escape_fragment( - // Macintosh has problems with small Russian letter 'r' - if( is1251 && c=='\xF0' ) { - // fixing that letter for most common charset - to_char('p'); - } else // fallback to default - encode(need_file_encode, '_', c); + encode(need_file_encode, '_', c); ); } break; @@ -506,7 +501,7 @@ int cstr_to_string_body_block(String::La pa_CORD_pos_advance(info->pos, fragment_length); String::C output(fragment_str, fragment_length); - output=Charset::escape(output, info->charsets->source()); + output=Charset::escape(output, info->charsets->client()); //throw Exception(0, 0, output); to_string(output);