--- parser3/src/classes/op.C 2002/03/18 15:29:45 1.74 +++ parser3/src/classes/op.C 2002/03/27 15:30:34 1.78 @@ -4,7 +4,7 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: op.C,v 1.74 2002/03/18 15:29:45 paf Exp $ + $Id: op.C,v 1.78 2002/03/27 15:30:34 paf Exp $ */ #include "classes.h" @@ -59,7 +59,7 @@ static void _untaint(Request& r, const S const String& lang_name=params->as_string(0, "lang must be string"); lang=untaint_lang_name2enum->get_int(lang_name); if(!lang) - throw Exception(0, 0, + throw Exception(0, &lang_name, "invalid taint language"); } @@ -82,7 +82,7 @@ static void _taint(Request& r, const Str const String& lang_name=params->as_string(0, "lang must be string"); lang=untaint_lang_name2enum->get_int(lang_name); if(!lang) - throw Exception(0, 0, + throw Exception(0, &lang_name, "invalid taint language"); } @@ -157,7 +157,7 @@ static void _while(Request& r, const Str int endless_loop_count=0; while(true) { if(++endless_loop_count>=MAX_LOOPS) // endless loop? - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "endless loop detected"); @@ -188,7 +188,7 @@ static void _for(Request& r, const Strin Value *delim_maybe_code=params->size()>4?¶ms->get(4):0; if(to-from>=MAX_LOOPS) // too long loop? - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "endless loop detected"); @@ -260,8 +260,7 @@ r.sql_connect_time+=t[1]-t[0]; // execute body try { r.write_assign_lang(r.process(body_code)); - - } catch(...) { // process/commit problem + } catch(...) { // process problem connection->mark_to_rollback(); /*re*/throw; } @@ -292,7 +291,7 @@ static void _case(Request& r, const Stri Switch_data *data=static_cast(r.classes_conf.get(*switch_data_name)); if(!data) - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "without switch"); @@ -460,7 +459,7 @@ static void _cache(Request& r, const Str retry=0; // prolonging our wait, than could cache_get it, without processing body_code } } - throw Exception(0, 0, + throw Exception(0, &file_spec, "locking problem"); } else { @@ -480,14 +479,16 @@ static void _cache(Request& r, const Str VHash& exception2vhash(Pool& pool, const Exception& e) { VHash& result=*new(pool) VHash(pool); Hash& hash=result.hash(0); - if(const String *type=e.type()) - hash.put(*exception_type_part_name, new(pool) VString(*type)); - if(const String *source=e.problem_source()) { - result.set_name(*source); + if(const char *type=e.type()) + hash.put(*exception_type_part_name, new(pool) VString(*new(pool) String(pool, type))); + if(const String *asource=e.problem_source()) { + String& source=*new(pool) String(pool); + source.append(*asource, String::UL_TAINTED, true/*forced*/); + result.set_name(source); - hash.put(*exception_source_part_name, new(pool) VString(*source)); + hash.put(*exception_source_part_name, new(pool) VString(source)); #ifndef NO_STRING_ORIGIN - const Origin& origin=source->origin(); + const Origin& origin=source.origin(); hash.put(*new(pool) String(pool, "file"), new(pool) VString(*new(pool) String(pool, origin.file))); hash.put(*new(pool) String(pool, "lineno"), @@ -499,7 +500,7 @@ VHash& exception2vhash(Pool& pool, const char *pcomment=(char *)pool.malloc(comment_size); memcpy(pcomment, ecomment, comment_size); hash.put(*exception_comment_part_name, - new(pool) VString(*new(pool) String(pool, pcomment, comment_size))); + new(pool) VString(*new(pool) String(pool, pcomment, comment_size, true/*tainted*/))); } hash.put(*exception_handled_part_name, new(pool) VBool(pool, false)); @@ -516,16 +517,19 @@ static void _try_operator(Request& r, co Value *result; // taking snapshot of request processing status - int stop_index=r.stack.top_index(); + //int ssexception_trace=r.exception_trace.top_index(); + int sstack=r.stack.top_index(); Value *sself=r.self, *sroot=r.root, *srcontext=r.rcontext; WContext *swcontext=r.wcontext; try { result=&r.process(body_code); } catch(const Exception& e) { // restoring request processing status - r.stack.top_index(stop_index); + //r.exception_trace.top_index(ssexception_trace); + r.stack.top_index(sstack); r.self=sself; r.root=sroot, r.rcontext=srcontext; r.wcontext=swcontext; + VHash& vhash=exception2vhash(pool, e); Junction *junction=catch_code.get_junction(); @@ -550,9 +554,9 @@ static void _throw_operator(Request& r, if(params->size()==1) { Value& param0=params->get(0); if(Hash *hash=param0.get_hash(&method_name)) { - const String *type=0; + const char *type=0; if(Value *value=static_cast(hash->get(*exception_type_part_name))) - type=&value->as_string(); + type=value->as_string().cstr(); const String *source=0; if(Value *value=static_cast(hash->get(*exception_source_part_name))) source=&value->as_string(); @@ -561,20 +565,18 @@ static void _throw_operator(Request& r, static_cast(hash->get(*exception_comment_part_name))) comment=value->as_string().cstr(); - throw Exception(type, 0, + throw Exception(type, source?source:&method_name, comment); } else - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "one-param version has hash param"); } else { - const String& type=params->as_string(0, "type must be string"); + const char *type=params->as_string(0, "type must be string").cstr(); const String& source=params->as_string(1, "source must be string"); const char *comment=params->as_string(2, "comment must be string").cstr(); - throw Exception(&type, 0, - &source, - comment); + throw Exception(type, &source, comment); } }