--- parser3/src/include/pa_request.h 2001/09/24 14:34:25 1.97 +++ parser3/src/include/pa_request.h 2001/11/19 12:17:05 1.111 @@ -2,10 +2,9 @@ Parser: request class decl. Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexander Petrosyan (http://paf.design.ru) - Author: Alexander Petrosyan (http://design.ru/paf) - - $Id: pa_request.h,v 1.97 2001/09/24 14:34:25 parser Exp $ + $Id: pa_request.h,v 1.111 2001/11/19 12:17:05 paf Exp $ */ #ifndef PA_REQUEST_H @@ -20,6 +19,7 @@ #include "pa_vclass.h" #include "pa_vobject.h" #include "pa_venv.h" +#include "pa_vstatus.h" #include "pa_vform.h" #include "pa_vmath.h" #include "pa_vrequest.h" @@ -49,7 +49,7 @@ class Methoded; /// Main workhorse. class Request : public Pooled { - friend Temp_lang; + friend class Temp_lang; public: /// some information from web server @@ -68,7 +68,8 @@ public: Request(Pool& apool, Info& ainfo, - String::Untaint_lang adefault_lang ///< all tainted data default untainting lang + uchar adefault_lang, ///< all tainted data default untainting lang + bool status_allowed ///< status class allowed ); ~Request() {} @@ -109,7 +110,8 @@ public: /// appending, sure of clean string inside void write_no_lang(const String& astring) { - wcontext->write(astring, String::UL_CLEAN); + wcontext->write(astring, + String::UL_CLEAN | flang&String::UL_OPTIMIZE_BIT); } /// appending string, passing language built into string being written void write_pass_lang(const String& astring) { @@ -119,13 +121,18 @@ public: void write_assign_lang(Value& avalue) { wcontext->write(avalue, flang); } + /// appending string, assigning untaint language + void write_assign_lang(const String& astring) { + wcontext->write(astring, flang); + } /// appending possible string, passing language built into string being written void write_pass_lang(Value& avalue) { wcontext->write(avalue, String::UL_PASS_APPENDED); } /// appending sure value, that would be converted to clean string void write_no_lang(Value& avalue) { - wcontext->write(avalue, String::UL_CLEAN); + wcontext->write(avalue, + String::UL_CLEAN | flang&String::UL_OPTIMIZE_BIT); } /// appending sure value, not VString void write_expr_result(Value& avalue) { @@ -141,6 +148,9 @@ public: /// returns the mime type of 'user_file_name_cstr' const String& mime_type_of(const char *user_file_name_cstr); + /// PCRE character tables + const unsigned char *pcre_tables(); + public: /// info from web server @@ -152,6 +162,8 @@ public: Methoded& OP; /// $env:fields VEnv env; + /// $status:fields + VStatus status; /// $form:elements VForm form; /// $math:constants @@ -173,13 +185,10 @@ public: /// connection SQL_Connection *connection; - /// PCRE character tables - unsigned char *pcre_tables; /// classes configured data Hash classes_conf; - private: // core data /// classes @@ -196,6 +205,12 @@ private: // core data */ uint anti_endless_execute_recoursion; + /// charset->pcre_tables + Hash CTYPE; + + /// stack trace + Stack trace; + private: // compile.C VStateless_class& real_compile(COMPILE_PARAMS); @@ -213,11 +228,11 @@ private: // execute.C private: // lang&raw - String::Untaint_lang flang; + uchar flang; private: // defaults - const String::Untaint_lang fdefault_lang; + const uchar fdefault_lang; Value *default_content_type; private: // mime types @@ -227,12 +242,12 @@ private: // mime types private: // lang manipulation - String::Untaint_lang set_lang(String::Untaint_lang alang) { - String::Untaint_lang result=flang; + uchar set_lang(uchar alang) { + uchar result=flang; flang=alang; return result; } - void restore_lang(String::Untaint_lang alang) { + void restore_lang(uchar alang) { flang=alang; } @@ -244,9 +259,9 @@ private: /// Auto-object used for temporary changing Request::flang. class Temp_lang { Request& frequest; - String::Untaint_lang saved_lang; + uchar saved_lang; public: - Temp_lang(Request& arequest, String::Untaint_lang alang) : + Temp_lang(Request& arequest, uchar alang) : frequest(arequest), saved_lang(arequest.set_lang(alang)) { } @@ -279,12 +294,16 @@ public: return get_as(index, false, msg); } /// handy expression auto-processing to double - double as_double(int index, Request& r) { - return get_processed(index, r).as_double(); + double as_double(int index, const char *msg, Request& r) { + return get_processed(index, msg, r).as_double(); } /// handy expression auto-processing to int - int as_int(int index, Request& r) { - return get_processed(index, r).as_int(); + int as_int(int index, const char *msg, Request& r) { + return get_processed(index, msg, r).as_int(); + } + /// handy expression auto-processing to bool + bool as_bool(int index, const char *msg, Request& r) { + return get_processed(index, msg, r).as_bool(); } /// handy string ensurer const String& as_string(int index, const char *msg) { @@ -297,14 +316,15 @@ private: Value& get_as(int index, bool as_junction, const char *msg) { Value& result=get(index); if((result.get_junction()!=0) ^ as_junction) - THROW(0, 0, + throw Exception(0, 0, &fmethod_name, "%s (parameter #%d)", msg, 1+index); + return result; } - Value& get_processed(int index, Request& r) { - return r.process(get(index), + Value& get_processed(int index, const char *msg, Request& r) { + return r.process(as_junction(index, msg), 0/*no name*/, false/*don't intercept string*/); }