--- parser3/src/classes/file.C 2013/07/21 14:45:32 1.227 +++ parser3/src/classes/file.C 2015/04/02 22:04:40 1.233 @@ -25,7 +25,7 @@ #include "pa_vregex.h" #include "pa_version.h" -volatile const char * IDENT_FILE_C="$Id: file.C,v 1.227 2013/07/21 14:45:32 moko Exp $"; +volatile const char * IDENT_FILE_C="$Id: file.C,v 1.233 2015/04/02 22:04:40 moko Exp $"; // defines @@ -354,7 +354,7 @@ static void _create(Request& r, MethodPa VFile& self=GET_SELF(r, VFile); if(const String* content_str=vcontent.get_string()){ - String::Body body=content_str->cstr_to_string_body_untaint(String::L_AS_IS); // explode content, honor tainting changes + String::Body body=content_str->cstr_to_string_body_untaint(String::L_AS_IS, r.connection(false), &r.charsets); // explode content, honor tainting changes if(asked_charset && is_text) body=Charset::transcode(body, r.charsets.source(), *asked_charset); self.set(true/*tainted*/, is_text, body.cstrm(), body.length(), file_name, vcontent_type, &r); @@ -450,7 +450,7 @@ static void pass_cgi_header_attribute( static void append_to_argv(Request& r, ArrayString& argv, const String* str){ if(!str->is_empty()) - argv+=new String(str->cstr_to_string_body_untaint(String::L_AS_IS, 0, &r.charsets), String::L_AS_IS); + argv+=new String(str->cstr_to_string_body_untaint(String::L_AS_IS, r.connection(false), &r.charsets), String::L_AS_IS); } /// @todo fix `` in perl - they produced flipping consoles and no output to perl @@ -474,19 +474,16 @@ 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"); - ECSTR("PARSER_VERSION", PARSER_VERSION); + ECSTR(PARSER_VERSION, PARSER_VERSION); // from Request.info ECSTR(DOCUMENT_ROOT, r.request_info.document_root); ECSTR(PATH_TRANSLATED, r.request_info.path_translated); @@ -521,7 +518,7 @@ static void _exec_cgi(Request& r, Method if(info.vstdin) { if(const String* sstdin=info.vstdin->get_string()) { // untaint stdin - in = new String(sstdin->cstr_to_string_body_untaint(String::L_AS_IS), String::L_AS_IS); + in = new String(sstdin->cstr_to_string_body_untaint(String::L_AS_IS, r.connection(false), &r.charsets), String::L_AS_IS); } else if(VFile* vfile=static_cast(info.vstdin->as("file"))) in->append_know_length((const char* )vfile->value_ptr(), vfile->value_size(), String::L_TAINTED); @@ -699,6 +696,7 @@ static void _list(Request& r, MethodPara } if(Value* value=options->get("filter")) { vfilter=value; + valid_options++; } if(valid_options!=options->count()) throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); @@ -739,9 +737,9 @@ static void _list(Request& r, MethodPara if(stat) { ffblk.stat_file(); *row+=VDouble(ffblk.size()).get_string(); - *row+=new String(String::Body::Format(ffblk.c_timestamp()), String::L_CLEAN); - *row+=new String(String::Body::Format(ffblk.m_timestamp()), String::L_CLEAN); - *row+=new String(String::Body::Format(ffblk.a_timestamp()), String::L_CLEAN); + *row+=new String(String::Body::Format((int)ffblk.c_timestamp()), String::L_CLEAN); + *row+=new String(String::Body::Format((int)ffblk.m_timestamp()), String::L_CLEAN); + *row+=new String(String::Body::Format((int)ffblk.a_timestamp()), String::L_CLEAN); } table+=row; } @@ -1224,6 +1222,7 @@ MFile::MFile(): Methoded("file") { // ^file:list[path] // ^file:list[path][regexp] + // ^file:list[path][$.filter[regexp] $.stat(true)] add_native_method("list", Method::CT_STATIC, _list, 1, 2); // ^file:lock[path]{code}