--- parser3/src/main/untaint.C 2001/08/28 10:30:28 1.60 +++ parser3/src/main/untaint.C 2001/10/05 16:26:05 1.64 @@ -2,10 +2,10 @@ Parser: String class part: untaint mechanizm. Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com) - Author: Alexander Petrosyan (http://design.ru/paf) + + $Id: untaint.C,v 1.64 2001/10/05 16:26:05 parser Exp $ */ -static const char *RCSId="$Id: untaint.C,v 1.60 2001/08/28 10:30:28 parser Exp $"; #include "pa_pool.h" #include "pa_string.h" @@ -159,6 +159,7 @@ char *String::store_to(char *dest, Untai Dictionary *typo_dict=user_typo_dict?user_typo_dict:default_typo_dict; bool whitespace=true; + bool need_to_close_http_header_quote=false; const Chunk *chunk=&head; do { const Chunk::Row *row=chunk->rows; @@ -215,7 +216,7 @@ char *String::store_to(char *dest, Untai memcpy(dest, row->item.ptr, row->item.size); dest+=row->item.size; break; - case UL_FILE_NAME: + case UL_FILE_SPEC: // tainted, untaint language: file [name] escape(switch(*src) { case ' ': to_char('_'); break; @@ -237,7 +238,7 @@ char *String::store_to(char *dest, Untai case '\"': to_string("\\\"", 2); break; _default; }); - *dest++='\"'; + need_to_close_http_header_quote=true; } else { memcpy(dest, row->item.ptr, row->item.size); dest+=row->item.size; @@ -294,13 +295,22 @@ char *String::store_to(char *dest, Untai _default; }); break; + case UL_XML: + escape(switch(*src) { + case '&': to_string("&", 5); break; + case '>': to_string(">", 4); break; + case '<': to_string("<", 4); break; + case '"': to_string(""", 6); break; + case '\'': to_string("'", 6); break; + _default; + }); + break; case UL_HTML: escape(switch(*src) { case '&': to_string("&", 5); break; case '>': to_string(">", 4); break; case '<': to_string("<", 4); break; case '"': to_string(""", 6); break; - //TODO: XSLT case '\'': to_string("'", 6); break; _default; }); break; @@ -333,7 +343,6 @@ char *String::store_to(char *dest, Untai case '\n': to_string("\\n", 2); break; - //TODO: XSLT case '\'': to_string("'", 6); break; _default; }); *dest=0; @@ -396,6 +405,9 @@ char *String::store_to(char *dest, Untai } chunk=row->link; } while(chunk); + + if(need_to_close_http_header_quote) + *dest++='\"'; break2: return dest; }