--- parser3/src/classes/file.C 2020/12/15 17:10:28 1.274 +++ parser3/src/classes/file.C 2024/09/13 04:01:22 1.279 @@ -1,8 +1,8 @@ /** @file Parser: @b file parser class. - Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ #include "pa_config_includes.h" @@ -26,7 +26,7 @@ #include "pa_vregex.h" #include "pa_version.h" -volatile const char * IDENT_FILE_C="$Id: file.C,v 1.274 2020/12/15 17:10:28 moko Exp $"; +volatile const char * IDENT_FILE_C="$Id: file.C,v 1.279 2024/09/13 04:01:22 moko Exp $"; // defines @@ -365,7 +365,7 @@ static void _create(Request& r, MethodPa String::Body body=content_str->cstr_to_string_body_untaint(String::L_AS_IS, r.connection(false), &r.charsets); // explode content, honor tainting changes self.set(true/*tainted*/, is_text, body.cstrm(), body.length(), file_name, vcontent_type, &r); } else { - VFile& fcontent=*vcontent.as_vfile(String::L_AS_IS); // can't be null + VFile& fcontent=*vcontent.as_vfile(); // can't be null if(mode){ self.set(fcontent, &is_text, file_name, vcontent_type, &r); if(is_text && !fcontent.is_text_mode()) @@ -528,7 +528,7 @@ static void _exec_cgi(Request& r, Method // untaint stdin in = String::C(sstdin->cstr_to_string_body_untaint(String::L_AS_IS, r.connection(false), &r.charsets)); } else - if(VFile* vfile=static_cast(info.vstdin->as("file"))){ + if(VFile* vfile=dynamic_cast(info.vstdin)){ in = String::C((const char* )vfile->value_ptr(), vfile->value_size()); in_is_text_mode = vfile->is_text_mode(); } else @@ -706,8 +706,8 @@ static void _list(Request& r, MethodPara vfilter=&voption; } if(vfilter) { - if(Value* value=vfilter->as(VREGEX_TYPE)) { - vregex=static_cast(value); + if(VRegex* value=dynamic_cast(vfilter)) { + vregex=value; } else if(vfilter->is_string()) { if(!vfilter->get_string()->trim().is_empty()) { vregex=new VRegex(r.charsets.source(), &vfilter->as_string(), 0/*options*/); @@ -736,12 +736,12 @@ static void _list(Request& r, MethodPara if(!vregex || vregex->exec(file_name_cstr, file_name_size, ovector, ovector_size)>=0) { Table::element_type row(new ArrayString); *row+=new String(pa_strdup(file_name_cstr, file_name_size), String::L_TAINTED); - *row+=new String(String::Body::Format(ffblk.is_dir(stat) ? 1 : 0), String::L_CLEAN); + *row+=new String(ffblk.is_dir(stat) ? "1" : "0", String::L_CLEAN); if(stat) { *row+=VDouble(ffblk.size()).get_string(); - *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); + *row+=new String(pa_uitoa(ffblk.c_timestamp()), String::L_CLEAN); + *row+=new String(pa_uitoa(ffblk.m_timestamp()), String::L_CLEAN); + *row+=new String(pa_uitoa(ffblk.a_timestamp()), String::L_CLEAN); } table+=row; } @@ -1120,7 +1120,7 @@ static void _base64(Request& r, MethodPa } static void _crc32(Request& r, MethodParams& params) { - unsigned long crc32 = 0; + uint crc32 = 0; if(&r.get_self() == file_class) { // ^file:crc32[file-name] if(params.count()) { @@ -1134,7 +1134,7 @@ static void _crc32(Request& r, MethodPar VFile& self=GET_SELF(r, VFile); crc32=pa_crc32(self.value_ptr(), self.value_size()); } - r.write(*new VInt(crc32)); + r.write(*new VDouble(crc32)); }