--- parser3/src/classes/Attic/root.C 2001/03/18 13:38:45 1.41 +++ parser3/src/classes/Attic/root.C 2001/03/18 16:32:24 1.43 @@ -3,7 +3,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: root.C,v 1.41 2001/03/18 13:38:45 paf Exp $ + $Id: root.C,v 1.43 2001/03/18 16:32:24 paf Exp $ */ #include @@ -48,16 +48,37 @@ 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"); + + Temp_lang temp_lang(r, String::Untaint_lang::AS_IS); // set temporarily as-is language + String result(r.process(*vbody).as_string()); // process marking tainted with that lang + result.change_lang(lang); // switch 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 @@ -245,9 +266,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);