--- parser3/src/classes/Attic/root.C 2001/03/11 08:44:39 1.13 +++ parser3/src/classes/Attic/root.C 2001/03/11 12:10:42 1.16 @@ -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.13 2001/03/11 08:44:39 paf Exp $ + $Id: root.C,v 1.16 2001/03/11 12:10:42 paf Exp $ */ #include "pa_request.h" @@ -14,7 +14,7 @@ static void _if(Request& r, Array *param r.autocalc( *static_cast(params->get(0)), 0/*no name*/, - false/*don't make it string*/).get_bool(); + false/*don't intercept string*/).get_bool(); if(condition) { Value& value=r.autocalc(*static_cast(params->get(1))); r.wcontext->write(value, String::Untaint_lang::PASS_APPENDED); @@ -24,6 +24,26 @@ static void _if(Request& r, Array *param } } +static void _untaint(Request& r, Array *params) { + const String& lang_name=r.autocalc(*static_cast(params->get(0))).as_string(); + String::Untaint_lang lang=static_cast( + untaint_lang_name_to_enum->get_int(lang_name)); + if(!lang) + R_THROW(0, 0, + &lang_name, + "invalid language"); + + Temp_lang temp_lang(r, lang); + Value& value=r.autocalc(*static_cast(params->get(1))); + r.wcontext->write(value, String::Untaint_lang::PASS_APPENDED); +} + + void initialize_root_class(Pool& pool, VClass& vclass) { - vclass.add_native_method("if", _if, 2, 3); // ^if(c){t} ^if(c){t}{f} + // ^if(condition){code-when-true} + // ^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} + vclass.add_native_method("untaint", _untaint, 2, 2); }