--- parser3/src/main/pa_request.C 2005/08/05 13:03:02 1.274.6.1 +++ parser3/src/main/pa_request.C 2006/11/16 18:03:13 1.282 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_REQUEST_C="$Date: 2005/08/05 13:03:02 $"; +static const char * const IDENT_REQUEST_C="$Date: 2006/11/16 18:03:13 $"; #include "pa_sapi.h" #include "pa_common.h" @@ -53,13 +53,13 @@ const char* ORIGINS_CONTENT_TYPE="text/p #define EXCEPTION_TYPE_PART_NAME "type" #define EXCEPTION_SOURCE_PART_NAME "source" #define EXCEPTION_COMMENT_PART_NAME "comment" -#define RESPONSE_BODY_FILE_NAME "file" // globals const String main_method_name(MAIN_METHOD_NAME); const String auto_method_name(AUTO_METHOD_NAME); const String content_disposition_name(CONTENT_DISPOSITION_NAME); +const String content_disposition_inline(CONTENT_DISPOSITION_INLINE); const String content_disposition_value(CONTENT_DISPOSITION_VALUE); const String content_disposition_filename_name(CONTENT_DISPOSITION_FILENAME_NAME); const String body_name(BODY_NAME); @@ -67,7 +67,6 @@ const String exception_type_part_name(EX const String exception_source_part_name(EXCEPTION_SOURCE_PART_NAME); const String exception_comment_part_name(EXCEPTION_COMMENT_PART_NAME); const String exception_handled_part_name(EXCEPTION_HANDLED_PART_NAME); -const String response_body_file_name(RESPONSE_BODY_FILE_NAME); // defines for statics @@ -78,6 +77,7 @@ const String response_body_file_name(RES #define POST_PROCESS_METHOD_NAME "postprocess" #define DOWNLOAD_NAME "download" #define CLASS_PATH_NAME "CLASS_PATH" +#define RESPONSE_BODY_FILE_NAME "file" // statics @@ -89,6 +89,7 @@ static const String conf_method_name(CON static const String post_process_method_name(POST_PROCESS_METHOD_NAME); static const String download_name(DOWNLOAD_NAME); static const String class_path_name(CLASS_PATH_NAME); +static const String response_body_file_name(RESPONSE_BODY_FILE_NAME); // defines @@ -107,7 +108,7 @@ Request::Request(SAPI_Info& asapi_info, wcontext(0), flang(adefault_lang), fconnection(0), - finterrupted(false), + finterrupted(false),fskip(SKIP_NOTHING), // public #ifdef RESOURCES_DEBUG @@ -220,7 +221,7 @@ void Request::configure_admin(VStateless if(Value* vcharsets=conf_class.get_element(charsets_name, conf_class, false)) { if(!vcharsets->is_string()) if(HashStringValue* charsets=vcharsets->get_hash()) - charsets->for_each(load_charset, &this->charsets); + charsets->for_each(load_charset, &this->charsets); else throw Exception("parser.runtime", 0, @@ -389,6 +390,13 @@ gettimeofday(&mt[2],NULL); body_value=response.fields().get(body_name); // $response:body if(!body_value) body_value=new VString(*body_string); // just result of ^main[] + // ensure that body_value has no just L_TAINTED parts left + if(body_value->is_string()) + { + String& untainted=*new String(); + untainted.append(*body_value->get_string(), flang); + body_value=new VString(untainted); + } // @postprocess if(Value* value=main_class.get_element(post_process_method_name, main_class, false)) @@ -488,6 +496,7 @@ frame.store_param(*new VTable(&stack_tra // future $response:body= // execute ^unhandled_exception[exception;stack] +exception_trace.clear(); // forget all about previous life, in case there would be error inside of this method, error handled would not be mislead by old stack contents (see extract_origin) body_string=&execute_method(frame, *method).as_string(); } } @@ -552,12 +561,12 @@ void Request::use_file(VStateless_class& file_spec=0; if(Value* element=main_class.get_element(class_path_name, main_class, false)) { if(element->is_string()) { - file_spec=file_readable(absolute(element->as_string()), file_name); // found at class_path? + file_spec=file_exist(absolute(element->as_string()), file_name); // found at class_path? } else if(Table *table=element->get_table()) { int size=table->count(); for(int i=size; i--; ) { const String& path=*(*table->get(i))[0]; - if((file_spec=file_readable(absolute(path), file_name))) + if((file_spec=file_exist(absolute(path), file_name))) break; // found along class_path } } else @@ -828,12 +837,14 @@ void Request::output_result(VFile* body_ if(vfile_name) { const String& sfile_name=vfile_name->as_string(); if(sfile_name!=NONAME_DAT) { - VHash& hash=*new VHash(); - HashStringValue &h=hash.hash(); if(as_attachment) + { + VHash& hash=*new VHash(); + HashStringValue &h=hash.hash(); h.put(value_name, new VString(content_disposition_value)); - h.put(content_disposition_filename_name, vfile_name); - response.fields().put(content_disposition_name, &hash); + h.put(content_disposition_filename_name, vfile_name); + response.fields().put(content_disposition_name, &hash); + } if(!body_file_content_type) body_file_content_type=new VString(mime_type_of(sfile_name.cstr())); @@ -852,7 +863,7 @@ void Request::output_result(VFile* body_ // prepare header: $response:fields without :body Add_header_attribute_info info(*this); - response.fields().for_each(add_header_attribute, &info); + response.fields().for_each(add_header_attribute, &info); if(body_file_content_type) if(HashStringValue *hash=body_file_content_type->get_hash()) @@ -905,19 +916,15 @@ const String& Request::mime_type_of(cons } #ifdef XML -GdomeDOMString_auto_ptr Request::transcode(const String& s) { +xmlChar* Request::transcode(const String& s) { return charsets.source().transcode(s); } -GdomeDOMString_auto_ptr Request::transcode(const String::Body s) { +xmlChar* Request::transcode(const String::Body s) { return charsets.source().transcode(s); } -const String& Request::transcode(GdomeDOMString* s) { - return charsets.source().transcode(s); -} - -const String& Request::transcode(xmlChar* s) { +const String& Request::transcode(const xmlChar* s) { return charsets.source().transcode(s); } #endif @@ -928,13 +935,15 @@ const Request::Trace Request::Exception_ if(!is_empty()) { result=bottom_value(); if(!problem_source) { // we don't know who trigged the bug? - problem_source=result.name(); // consider the stack-top-guy did that + problem_source=result.name(); // consider the stack-top-guy (we usually know source of next-from-throw-point exception) did that fbottom++; } else if(result.name()==problem_source) // it is that same guy? fbottom++; // throw away that trace - // else stack top contains not us, - // leaving result intact - // it would help ^throw + else { + // stack top contains not us, + // leaving result intact + // it would help ^throw + } } return result;