--- parser3/src/main/pa_request.C 2008/05/30 12:25:21 1.293 +++ parser3/src/main/pa_request.C 2009/07/06 12:20:01 1.305 @@ -1,11 +1,11 @@ /** @file Parser: request class main part. @see compile.C and execute.C. - Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_REQUEST_C="$Date: 2008/05/30 12:25:21 $"; +static const char * const IDENT_REQUEST_C="$Date: 2009/07/06 12:20:01 $"; #include "pa_sapi.h" #include "pa_common.h" @@ -14,7 +14,7 @@ static const char * const IDENT_REQUEST_ #include "pa_vclass.h" #include "pa_globals.h" #include "pa_vint.h" -#include "pa_vmethod_frame_global.h" +#include "pa_vmethod_frame.h" #include "pa_types.h" #include "pa_venv.h" #include "pa_vmath.h" @@ -126,7 +126,7 @@ Request::Request(SAPI_Info& asapi_info, form(*new VForm(charsets, arequest_info)), mail(*new VMail), response(*new VResponse(arequest_info, charsets)), - cookie(*new VCookie), + cookie(*new VCookie(charsets, arequest_info)), console(*new VConsole), // private @@ -160,7 +160,7 @@ Request::Request(SAPI_Info& asapi_info, if(status_allowed) classes().put(String::Body(STATUS_CLASS_NAME), new VStatus()); // request class - classes().put(String::Body(REQUEST_CLASS_NAME), new VRequest(arequest_info, charsets)); + classes().put(String::Body(REQUEST_CLASS_NAME), new VRequest(arequest_info, charsets, form)); // cookie class classes().put(String::Body(COOKIE_CLASS_NAME), &cookie); // console class @@ -306,9 +306,6 @@ struct timeval mt[10]; gettimeofday(&mt[0],NULL); #endif try { - // filling cookies - cookie.fill_fields(request_info); - // filling mail received mail.fill_received(*this); @@ -391,13 +388,6 @@ 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)) @@ -405,15 +395,14 @@ gettimeofday(&mt[2],NULL); if(const Method *method=junction->method) { // preparing to pass parameters to // @postprocess[data] - VMethodFrameGlobal frame(/*method->name, */ *junction, 0/*no parent*/); + VMethodFrame frame(/*method->name, */ *junction, 0/*no parent*/); frame.set_self(main_class); - frame.store_param(*body_value); + frame.store_params(&body_value, 1); body_value=&execute_method(frame, *method).as_value(); } - VFile* body_file=body_value->as_vfile( - String::L_UNSPECIFIED, &charsets); + VFile* body_file=body_value->as_vfile(flang, &charsets); #ifdef RESOURCES_DEBUG //measure:after postprocess @@ -467,11 +456,9 @@ t[9]-t[3] if(const Method *method=junction->method) { // preparing to pass parameters to // @unhandled_exception[exception;stack] - VMethodFrameGlobal frame(/*method->name, */ *junction, 0/*no caller*/); + VMethodFrame frame(/*method->name, */ *junction, 0/*no caller*/); frame.set_self(main_class); - // $exception - frame.store_param(details.vhash); // $stack[^table::create{name file lineno colno}] Table::columns_type stack_trace_columns(new ArrayString); *stack_trace_columns+=new String("name"); @@ -494,7 +481,8 @@ t[9]-t[3] stack_trace+=row; } - frame.store_param(*new VTable(&stack_trace)); + Value *params[]={&details.vhash, new VTable(&stack_trace)}; + frame.store_params(params, 2); // future $response:body= // execute ^unhandled_exception[exception;stack] @@ -515,7 +503,7 @@ t[9]-t[3] } VString body_vstring(*body_string); - VFile* body_file=body_vstring.as_vfile(String::L_UNSPECIFIED, &charsets); + VFile* body_file=body_vstring.as_vfile(flang, &charsets); // conditionally log it Value* vhandled=details.vhash.hash().get(exception_handled_part_name); @@ -605,22 +593,27 @@ void Request::use_buf(VStateless_class& // temporary zero @auto so to maybe-replace it in compiled code Temp_method temp_method_auto(aclass, auto_method_name, 0); - // compile loaded class - VStateless_class& cclass=compile(&aclass, source, main_alias, file_no, line_no_offset); + // compile loaded classes + ArrayClass& cclasses=compile(&aclass, source, main_alias, file_no, line_no_offset); - // locate and execute possible @conf[] static VString* vfilespec= new VString(*new String(file_list[file_no], String::L_TAINTED)); - Execute_nonvirtual_method_result executed=execute_nonvirtual_method(cclass, - conf_method_name, vfilespec, - false/*no string result needed*/); - if(executed.method) - configure_admin(cclass/*, executed.method->name*/); - - // locate and execute possible @auto[] static - execute_nonvirtual_method(cclass, - auto_method_name, vfilespec, - false/*no result needed*/); + + for(size_t i=0; iname*/); + + // locate and execute possible @auto[] static + execute_nonvirtual_method(cclass, + auto_method_name, vfilespec, + false/*no result needed*/); + } } const String& Request::relative(const char* apath, const String& relative_name) { @@ -668,14 +661,15 @@ static void add_header_attribute( || name==CHARSET_NAME) return; - const char* aname=String(name, String::L_URI).cstr(String::L_UNSPECIFIED, 0, &info->r.charsets); + const char* aname=String(name, String::L_TAINTED).taint_cstr(String::L_URI, 0, &info->r.charsets); SAPI::add_header_attribute(info->r.sapi_info, - aname, - attributed_meaning_to_string(*value, String::L_URI, false).cstr(String::L_UNSPECIFIED, 0, &info->r.charsets)); + aname, + attributed_meaning_to_string(*value, String::L_URI, false).untaint_cstr(String::L_AS_IS, 0, &info->r.charsets) + ); if(strcasecmp(aname, "last-modified")==0) - info->add_last_modified = false; + info->add_last_modified=false; } static void output_sole_piece(Request& r, @@ -980,10 +974,10 @@ Request::Exception_details Request::get_ // $.comment if(const char* comment=e.comment(true)) hash.put(exception_comment_part_name, - new VString(*new String(comment, 0, true/*tainted*/))); + new VString(*new String(comment, String::L_TAINTED))); // $.handled(0) - hash.put(exception_handled_part_name, new VBool(false)); + hash.put(exception_handled_part_name, &VBool::get(false)); return Request::Exception_details(trace, problem_source, vhash); }