--- parser3/src/classes/Attic/root.C 2001/03/13 17:17:25 1.40 +++ parser3/src/classes/Attic/root.C 2001/03/21 14:06:42 1.47 @@ -3,16 +3,16 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: root.C,v 1.40 2001/03/13 17:17:25 paf Exp $ + $Id: root.C,v 1.47 2001/03/21 14:06:42 paf Exp $ */ #include #include +#include "pa_common.h" #include "pa_request.h" #include "_root.h" #include "pa_vint.h" -#include "pa_common.h" static void _if(Request& r, const String& method_name, Array *params) { Value& condition_code=*static_cast(params->get(0)); @@ -48,16 +48,40 @@ static void _untaint(Request& r, const S "invalid untaint language"); { - Temp_lang temp_lang(r, lang); Value *vbody=static_cast(params->get(1)); // forcing ^untaint[]{this param type} r.fail_if_junction_(false, *vbody, method_name, "body must be junction"); - r.write_pass_lang(r.process(*vbody)); + Temp_lang temp_lang(r, lang); // set temporarily specified ^untaint[language; + r.write_pass_lang(r.process(*vbody)); // process marking tainted with that lang + } +} + +static void _taint(Request& r, const String& method_name, Array *params) { + const String& lang_name=r.process(*static_cast(params->get(0))).as_string(); + String::Untaint_lang lang=static_cast( + untaint_lang_name2enum->get_int(lang_name)); + if(!lang) + RTHROW(0, 0, + &lang_name, + "invalid taint language"); + + { + Value *vbody=static_cast(params->get(1)); + // forcing ^untaint[]{this param type} + r.fail_if_junction_(true, *vbody, + method_name, "body must not be junction"); + + // set temporarily as-is language + Temp_lang temp_lang(r, String::UL_AS_IS); + String result(r.pool()); + result.append( + r.process(*vbody).as_string(), // process marking tainted with that lang + lang, true); // force result language to specified + r.write_pass_lang(result); } } - static void _process(Request& r, const String& method_name, Array *params) { // calculate pseudo file name of processed chars @@ -191,9 +215,9 @@ static void _eval(Request& r, const Stri method_name, "fmt must not be junction"); Pool& pool=r.pool(); - String *string=new(pool) String(pool); - string->APPEND_CONST(format(pool, result->get_double(), fmt.as_string().cstr())); - result=new(pool) VString(*string); + String& string=*new(pool) String(pool); + string.APPEND_CONST(format(pool, result->get_double(), fmt.as_string().cstr())); + result=new(pool) VString(string); } r.write_no_lang(*result); } @@ -245,9 +269,12 @@ void initialize_root_class(Pool& pool, V // ^if(condition){code-when-true}{code-when-false} vclass.add_native_method("if", _if, 2, 3); - // ^untaint[as-is|sql|js|html|html-typo]{code} + // ^untaint[as-is|uri|sql|js|html|html-typo]{code} vclass.add_native_method("untaint", _untaint, 2, 2); + // ^taint[as-is|uri|sql|js|html|html-typo]{code} + vclass.add_native_method("taint", _taint, 2, 2); + // ^process[code] vclass.add_native_method("process", _process, 1, 1);