--- parser3/src/classes/file.C 2002/11/25 14:10:51 1.104 +++ parser3/src/classes/file.C 2003/01/29 13:31:30 1.107.2.2 @@ -1,11 +1,11 @@ /** @file Parser: @b file parser class. - Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_FILE_C="$Date: 2002/11/25 14:10:51 $"; +static const char* IDENT_FILE_C="$Date: 2003/01/29 13:31:30 $"; #include "pa_config_includes.h" @@ -78,7 +78,7 @@ static const char *suexec_safe_env_lst[] class MFile : public Methoded { public: // VStateless_class - Value *create_new_value(Pool& pool) { return new(pool) VFile(pool); } + ValuePtr create_new_value() { return ValuePtr(new VFile()); } public: // Methoded bool used_directly() { return true; } @@ -116,6 +116,10 @@ static void _move(Request& r, const Stri r.absolute(vto_file_name.as_string())); } +static void _load_pass_param(const Hash::Key& key, Hash::Val *value, void *info) { + Hash& dest=*static_cast(info); + dest.put(key, value); +} static void _load(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); Value& vmode_name=params-> as_no_junction(0, "mode must not be code"); @@ -135,7 +139,7 @@ static void _load(Request& r, const Stri ); char *user_file_name=params->size()>alt_filename_param_index? - params->as_string(alt_filename_param_index, "filename must be string").cstr(String::UL_FILE_SPEC) + params->as_string(alt_filename_param_index, "filename must be string") :lfile_name.cstr(String::UL_FILE_SPEC); Value *vcontent_type=0; @@ -146,6 +150,8 @@ static void _load(Request& r, const Stri VFile& self=*static_cast(r.get_self()); self.set(true/*tainted*/, data, size, user_file_name, vcontent_type); + if(fields) + fields->for_each(_load_pass_param, &self.fields()); } static void _stat(Request& r, const String& method_name, MethodParams *params) { @@ -572,8 +578,12 @@ static void _fullpath(Request& r, const // /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; + + if(document_root_length>0) { + char last_char=r.info.document_root[document_root_length-1]; + if(last_char == '/' || last_char == '\\') + --document_root_length; + } result=&full_disk_path.mid(document_root_length, full_disk_path.size()); } r.write_assign_lang(*result);