--- parser3/src/classes/op.C 2010/07/05 05:54:46 1.201 +++ parser3/src/classes/op.C 2010/11/15 23:31:08 1.205 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_OP_C="$Date: 2010/07/05 05:54:46 $"; +static const char * const IDENT_OP_C="$Date: 2010/11/15 23:31:08 $"; #include "classes.h" #include "pa_vmethod_frame.h" @@ -81,6 +81,7 @@ public: ULN("optimized-html", HTML|String::L_OPTIMIZE_BIT); ULN("regex", REGEX); ULN("parser-code", PARSER_CODE); + ULN("json", JSON); #undef ULN } } untaint_lang_name2enum; @@ -144,6 +145,13 @@ static void _taint(Request& r, MethodPar } } +static void _apply_taint(Request& r, MethodParams& params) { + String::Language lang=params.count()==1 ? String::L_AS_IS : get_untaint_lang(params, 0); + const String &sbody=params.as_string(params.count()-1, "body must be string"); + String::Body result_body=sbody.cstr_to_string_body_untaint(lang, 0, &r.charsets); + r.write_pass_lang(*new String(result_body, String::L_AS_IS)); +} + static void _process(Request& r, MethodParams& params) { Method* main_method; @@ -220,10 +228,10 @@ static void _process(Request& r, MethodP // after restoring current-request-lang // maybe-execute @main[] if(main_method) { - // temporarily set method_frame's self to target_self - Temp_method_frame_self tmfs(*r.get_method_frame(), *target_self); - // execute! - r.execute(*main_method->parser_code); + VMethodFrame frame(*main_method, r.get_method_frame()->caller(), *target_self); + frame.empty_params(); + r.op_call(frame); + r.write_pass_lang(frame.result()); } } @@ -290,7 +298,7 @@ static void _use(Request& r, MethodParam Value& vfile=params.as_no_junction(0, FILE_NAME_MUST_NOT_BE_CODE); // _use could be called from the parser3 method only, so caller is always defined - r.use_file(r.main_class, vfile.as_string(), r.get_method_filename(r.get_method_frame()->caller()->junction.method)); + r.use_file(r.main_class, vfile.as_string(), r.get_method_filename(&r.get_method_frame()->caller()->method)); } static void set_skip(Request& r, Request::Skip askip) { @@ -899,6 +907,9 @@ VClassMAIN::VClassMAIN(): VClass() { // ^taint[as-is|uri|sql|js|html|html-typo|regex|parser-code]{code} add_native_method("taint", Method::CT_ANY, _taint, 1, 2, Method::CO_WITHOUT_FRAME); + // ^apply-taint[untaint lang][string] + add_native_method("apply-taint", Method::CT_ANY, _apply_taint, 1, 2, Method::CO_WITHOUT_FRAME); + // ^process[code] add_native_method("process", Method::CT_ANY, _process, 1, 3);