Annotation of parser3/src/classes/root.C, revision 1.17
1.1 paf 1: /*
1.10 paf 2: Parser
3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.12 paf 4: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.10 paf 5:
1.17 ! paf 6: $Id: root.C,v 1.16 2001/03/11 12:10:42 paf Exp $
1.1 paf 7: */
8:
9: #include "pa_request.h"
1.8 paf 10: #include "_root.h"
1.1 paf 11:
1.6 paf 12: static void _if(Request& r, Array *params) {
1.2 paf 13: bool condition=
14: r.autocalc(
1.6 paf 15: *static_cast<Value *>(params->get(0)),
1.11 paf 16: 0/*no name*/,
1.14 paf 17: false/*don't intercept string*/).get_bool();
1.6 paf 18: if(condition) {
19: Value& value=r.autocalc(*static_cast<Value *>(params->get(1)));
1.9 paf 20: r.wcontext->write(value, String::Untaint_lang::PASS_APPENDED);
1.6 paf 21: } else if(params->size()==3) {
22: Value& value=r.autocalc(*static_cast<Value *>(params->get(2)));
1.9 paf 23: r.wcontext->write(value, String::Untaint_lang::PASS_APPENDED);
1.6 paf 24: }
1.1 paf 25: }
26:
1.15 paf 27: static void _untaint(Request& r, Array *params) {
28: const String& lang_name=r.autocalc(*static_cast<Value *>(params->get(0))).as_string();
29: String::Untaint_lang lang=static_cast<String::Untaint_lang>(
1.16 paf 30: untaint_lang_name_to_enum->get_int(lang_name));
1.15 paf 31: if(!lang)
32: R_THROW(0, 0,
33: &lang_name,
34: "invalid language");
35:
36: Temp_lang temp_lang(r, lang);
1.17 ! paf 37: Value *value=static_cast<Value *>(params->get(1));
! 38: // forcing ^untaint[]{param type}
! 39: if(!value->get_junction())
! 40: R_THROW(0, 0,
! 41: &value->as_string(),
! 42: "untaint body must be junction");
! 43:
! 44: value=&r.autocalc(*value);
! 45: r.wcontext->write(*value, String::Untaint_lang::PASS_APPENDED);
1.15 paf 46: }
47:
48:
1.7 paf 49: void initialize_root_class(Pool& pool, VClass& vclass) {
1.15 paf 50: // ^if(condition){code-when-true}
51: // ^if(condition){code-when-true}{code-when-false}
52: vclass.add_native_method("if", _if, 2, 3);
53:
54: // ^untaint[as-is|sql|js|html|html-typo]{code}
55: vclass.add_native_method("untaint", _untaint, 2, 2);
1.1 paf 56: }
E-mail: