--- parser3/src/classes/file.C 2015/01/12 12:13:25 1.232 +++ parser3/src/classes/file.C 2015/04/08 18:08:52 1.234 @@ -25,7 +25,7 @@ #include "pa_vregex.h" #include "pa_version.h" -volatile const char * IDENT_FILE_C="$Id: file.C,v 1.232 2015/01/12 12:13:25 misha Exp $"; +volatile const char * IDENT_FILE_C="$Id: file.C,v 1.234 2015/04/08 18:08:52 moko Exp $"; // defines @@ -387,7 +387,7 @@ static void _stat(Request& r, MethodPara static bool is_safe_env_key(const char* key) { for(const char* validator=key; *validator; validator++) { char c=*validator; - if(!(c>='A' && c<='Z' || c>='0' && c<='9' || c=='_' || c=='-')) + if(!( (c>='A' && c<='Z') || (c>='0' && c<='9') || (c=='_' || c=='-') )) return false; } #ifdef PA_SAFE_MODE @@ -474,15 +474,12 @@ static void _exec_cgi(Request& r, Method env.put( \ String::Body(#name), \ String::Body(*value_cstr?value_cstr:0)); \ - // passing SAPI::environment - if(const char *const *pairs=SAPI::environment(r.sapi_info)) { - while(const char* pair=*pairs++) - if(const char* eq_at=strchr(pair, '=')) - if(eq_at[1]) // has value - env.put( - pa_strdup(pair, eq_at-pair), - pa_strdup(eq_at+1)); - } + // passing environment + for(SAPI::Env::Iterator i(r.sapi_info); i; i.next() ) + env.put( + i.key(), + i.value() + ); // const ECSTR(GATEWAY_INTERFACE, "CGI/1.1"); @@ -706,18 +703,19 @@ static void _list(Request& r, MethodPara } else { vfilter=&voption; } - if(vfilter) + if(vfilter) { if(Value* value=vfilter->as(VREGEX_TYPE)) { vregex=static_cast(value); } else if(vfilter->is_string()) { if(!vfilter->get_string()->trim().is_empty()) { vregex=new VRegex(r.charsets.source(), &vfilter->as_string(), 0/*options*/); - vregex->study(); - vrcleaner.vregex=vregex; - } + vregex->study(); + vrcleaner.vregex=vregex; + } } else { throw Exception(PARSER_RUNTIME, 0, "filter must be regex or string"); } + } } }