--- parser3/src/classes/file.C 2002/09/18 09:44:51 1.100 +++ parser3/src/classes/file.C 2002/10/21 08:22:17 1.102 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_FILE_C="$Date: 2002/09/18 09:44:51 $"; +static const char* IDENT_FILE_C="$Date: 2002/10/21 08:22:17 $"; #include "pa_config_includes.h" @@ -421,7 +421,7 @@ static void _list(Request& r, const Stri char *file_name_cstr=(char *)pool.malloc(file_name_size); memcpy(file_name_cstr, ffblk.ff_name, file_name_size); String &file_name=*new(pool) String(pool); - file_name.APPEND(file_name_cstr, file_name_size, String::UL_FILE_SPEC, + file_name.APPEND_TAINTED(file_name_cstr, file_name_size, method_name.origin().file, method_name.origin().line); Array& row=*new(pool) Array(pool); @@ -545,6 +545,22 @@ static void _justext(Request& r, const S r.write_assign_lang(file_spec.mid(afterdot, file_spec.size())); } +static void _fullpath(Request& r, const String& method_name, MethodParams *params) { + const String& file_spec=params->as_string(0, "file name must be string"); + const String *result; + if(file_spec.first_char()=='/') + result=&file_spec; + else { + // /some/page.html: ^file:fullpath[a.gif] => /some/a.gif + const String& full_disk_path=r.absolute(file_spec); + size_t document_root_length=strlen(r.info.document_root); + if(document_root_length>0) + --document_root_length; + result=&full_disk_path.mid(document_root_length, full_disk_path.size()); + } + r.write_assign_lang(*result); +} + // constructor @@ -595,6 +611,8 @@ MFile::MFile(Pool& apool) : Methoded(apo add_native_method("justname", Method::CT_STATIC, _justname, 1, 1); // ^file:justext[/a/some.tar.gz]=gz add_native_method("justext", Method::CT_STATIC, _justext, 1, 1); + // /some/page.html: ^file:fullpath[a.gif] => /some/a.gif + add_native_method("fullpath", Method::CT_STATIC, _fullpath, 1, 1); } // global variable