|
|
| version 1.151, 2007/02/07 15:50:32 | version 1.154, 2007/04/13 16:58:15 |
|---|---|
| Line 36 static const char * const IDENT_FILE_C=" | Line 36 static const char * const IDENT_FILE_C=" |
| #define NAME_NAME "name" | #define NAME_NAME "name" |
| #define FILE_NAME_MUST_BE_STRING "file name must be string" | |
| #define FILE_NAME_MUST_NOT_BE_CODE "file name must not be code" | |
| // externs | // externs |
| extern String sql_limit_name; | extern String sql_limit_name; |
| Line 126 static bool is_text_mode(const String& m | Line 129 static bool is_text_mode(const String& m |
| static void _save(Request& r, MethodParams& params) { | static void _save(Request& r, MethodParams& params) { |
| Value& vmode_name=params. as_no_junction(0, "mode must not be code"); | Value& vmode_name=params. as_no_junction(0, "mode must not be code"); |
| Value& vfile_name=params.as_no_junction(1, "file name must not be code"); | Value& vfile_name=params.as_no_junction(1, FILE_NAME_MUST_NOT_BE_CODE); |
| // save | // save |
| GET_SELF(r, VFile).save(r.absolute(vfile_name.as_string()), | GET_SELF(r, VFile).save(r.absolute(vfile_name.as_string()), |
| Line 134 static void _save(Request& r, MethodPara | Line 137 static void _save(Request& r, MethodPara |
| } | } |
| static void _delete(Request& r, MethodParams& params) { | static void _delete(Request& r, MethodParams& params) { |
| Value& vfile_name=params.as_no_junction(0, "file name must not be code"); | Value& vfile_name=params.as_no_junction(0, FILE_NAME_MUST_NOT_BE_CODE); |
| // unlink | // unlink |
| file_delete(r.absolute(vfile_name.as_string())); | file_delete(r.absolute(vfile_name.as_string())); |
| Line 182 static void _copy(Request& r, MethodPara | Line 185 static void _copy(Request& r, MethodPara |
| String from_spec = r.absolute(vfrom_file_name.as_string()); | String from_spec = r.absolute(vfrom_file_name.as_string()); |
| const String& to_spec = r.absolute(vto_file_name.as_string()); | const String& to_spec = r.absolute(vto_file_name.as_string()); |
| create_dir_for_file(to_spec); | // create_dir_for_file(to_spec); |
| file_write_action_under_lock( | file_write_action_under_lock( |
| to_spec, | to_spec, |
| Line 199 static void _load_pass_param( | Line 202 static void _load_pass_param( |
| } | } |
| static void _load(Request& r, MethodParams& params) { | static void _load(Request& r, MethodParams& params) { |
| Value& vmode_name=params. as_no_junction(0, "mode must not be code"); | Value& vmode_name=params. as_no_junction(0, "mode must not be code"); |
| const String& lfile_name=r.absolute(params.as_no_junction(1, "file name must not be code").as_string()); | const String& lfile_name=r.absolute(params.as_no_junction(1, FILE_NAME_MUST_NOT_BE_CODE).as_string()); |
| Value* third_param=params.count()>2?¶ms.as_no_junction(2, "filename or options must not be code") | Value* third_param=params.count()>2?¶ms.as_no_junction(2, "filename or options must not be code") |
| :0; | :0; |
| HashStringValue* third_param_hash=third_param?third_param->get_hash():0; | HashStringValue* third_param_hash=third_param?third_param->get_hash():0; |
| Line 226 static void _load(Request& r, MethodPara | Line 229 static void _load(Request& r, MethodPara |
| ); | ); |
| const char *user_file_name=params.count()>alt_filename_param_index? | const char *user_file_name=params.count()>alt_filename_param_index? |
| params.as_string(alt_filename_param_index, "filename must be string").cstr() | params.as_string(alt_filename_param_index, FILE_NAME_MUST_BE_STRING).cstr() |
| :lfile_name.cstr(String::L_FILE_SPEC); | :lfile_name.cstr(String::L_FILE_SPEC); |
| Value* vcontent_type=0; | Value* vcontent_type=0; |
| Line 252 static void _create(Request& r, MethodPa | Line 255 static void _create(Request& r, MethodPa |
| "only text mode is currently supported"); | "only text mode is currently supported"); |
| const char* user_file_name_cstr=r.absolute( | const char* user_file_name_cstr=r.absolute( |
| params.as_no_junction(1, "file name must not be code").as_string()).cstr(String::L_FILE_SPEC); | params.as_no_junction(1, FILE_NAME_MUST_NOT_BE_CODE).as_string()).cstr(String::L_FILE_SPEC); |
| const String& content=params.as_string(2, "content must be string"); | const String& content=params.as_string(2, "content must be string"); |
| const char* content_cstr=content.cstr(String::L_UNSPECIFIED); // explode content, honor tainting changes | const char* content_cstr=content.cstr(String::L_UNSPECIFIED); // explode content, honor tainting changes |
| Line 264 static void _create(Request& r, MethodPa | Line 267 static void _create(Request& r, MethodPa |
| } | } |
| static void _stat(Request& r, MethodParams& params) { | static void _stat(Request& r, MethodParams& params) { |
| Value& vfile_name=params.as_no_junction(0, "file name must not be code"); | Value& vfile_name=params.as_no_junction(0, FILE_NAME_MUST_NOT_BE_CODE); |
| const String& lfile_name=vfile_name.as_string(); | const String& lfile_name=vfile_name.as_string(); |
| Line 346 static void pass_cgi_header_attribute( | Line 349 static void pass_cgi_header_attribute( |
| static void _exec_cgi(Request& r, MethodParams& params, | static void _exec_cgi(Request& r, MethodParams& params, |
| bool cgi) { | bool cgi) { |
| Value& vfile_name=params.as_no_junction(0, "file name must not be code"); | Value& vfile_name=params.as_no_junction(0, FILE_NAME_MUST_NOT_BE_CODE); |
| const String& script_name=r.absolute(vfile_name.as_string()); | const String& script_name=r.absolute(vfile_name.as_string()); |
| Line 425 static void _exec_cgi(Request& r, Method | Line 428 static void _exec_cgi(Request& r, Method |
| // influence tainting | // influence tainting |
| // main target -- URLencoding of tainted pieces to String::L_URI lang | // main target -- URLencoding of tainted pieces to String::L_URI lang |
| Temp_client_charset temp(r.charsets, charset? *charset: r.charsets.source()); | Temp_client_charset temp(r.charsets, charset? *charset: r.charsets.source()); |
| for(size_t i=2; i<params.count(); i++) { | for(size_t i=2; i<params.count(); i++) { |
| const String& param=params.as_string(i, "parameter must be string"); | Value& param=params.as_no_junction(i, "parameter must not be code"); |
| if(param.length() > 0) { | if(param.is_defined()){ |
| argv+=new String(param.cstr_to_string_body(String::L_UNSPECIFIED, 0, &r.charsets), String::L_AS_IS); | if(param.is_string()){ |
| const String& pstring=*param.get_string(); | |
| if(pstring.length() > 0) { | |
| argv+=new String(pstring.cstr_to_string_body(String::L_UNSPECIFIED, 0, &r.charsets), String::L_AS_IS); | |
| } | |
| } else { | |
| Table* ptable=param.get_table(); | |
| if(ptable){ | |
| for(size_t i=0; i<ptable->count(); i++) { | |
| argv+=new String(ptable->get(i)->get(0)->cstr_to_string_body(String::L_UNSPECIFIED, 0, &r.charsets), String::L_AS_IS); | |
| } | |
| } else { | |
| throw Exception("parser.runtime", | |
| 0, | |
| "parameter must be string or table"); | |
| } | |
| } | |
| } | } |
| } | } |
| } | } |
| Line 611 static void lock_execute_body(int , void | Line 631 static void lock_execute_body(int , void |
| info.r->write_assign_lang(info.r->process(*info.body_code)); | info.r->write_assign_lang(info.r->process(*info.body_code)); |
| }; | }; |
| static void _lock(Request& r, MethodParams& params) { | static void _lock(Request& r, MethodParams& params) { |
| const String& file_spec=r.absolute(params.as_string(0, "file name must be string")); | const String& file_spec=r.absolute(params.as_string(0, FILE_NAME_MUST_BE_STRING)); |
| Lock_execute_body_info info={ | Lock_execute_body_info info={ |
| &r, | &r, |
| ¶ms.as_junction(1, "body must be code") | ¶ms.as_junction(1, "body must be code") |
| Line 636 static int lastposafter(const String& s, | Line 656 static int lastposafter(const String& s, |
| } | } |
| static void _find(Request& r, MethodParams& params) { | static void _find(Request& r, MethodParams& params) { |
| const String& file_name=params.as_no_junction(0, "file name must not be code").as_string(); | const String& file_name=params.as_no_junction(0, FILE_NAME_MUST_NOT_BE_CODE).as_string(); |
| const String* file_spec; | const String* file_spec; |
| if(file_name.first_char()=='/') | if(file_name.first_char()=='/') |
| file_spec=&file_name; | file_spec=&file_name; |
| Line 673 static void _find(Request& r, MethodPara | Line 693 static void _find(Request& r, MethodPara |
| } | } |
| static void _dirname(Request& r, MethodParams& params) { | static void _dirname(Request& r, MethodParams& params) { |
| const String& file_spec=params.as_string(0, "file name must be string"); | const String& file_spec=params.as_string(0, FILE_NAME_MUST_BE_STRING); |
| // /a/some.tar.gz > /a | // /a/some.tar.gz > /a |
| // /a/b/ > /a | // /a/b/ > /a |
| int afterslash=lastposafter(file_spec, 0, "/", 1, true); | int afterslash=lastposafter(file_spec, 0, "/", 1, true); |
| Line 684 static void _dirname(Request& r, MethodP | Line 704 static void _dirname(Request& r, MethodP |
| } | } |
| static void _basename(Request& r, MethodParams& params) { | static void _basename(Request& r, MethodParams& params) { |
| const String& file_spec=params.as_string(0, "file name must be string"); | const String& file_spec=params.as_string(0, FILE_NAME_MUST_BE_STRING); |
| // /a/some.tar.gz > some.tar.gz | // /a/some.tar.gz > some.tar.gz |
| int afterslash=lastposafter(file_spec, 0, "/", 1); | int afterslash=lastposafter(file_spec, 0, "/", 1); |
| r.write_assign_lang(file_spec.mid(afterslash, file_spec.length())); | r.write_assign_lang(file_spec.mid(afterslash, file_spec.length())); |
| } | } |
| static void _justname(Request& r, MethodParams& params) { | static void _justname(Request& r, MethodParams& params) { |
| const String& file_spec=params.as_string(0, "file name must be string"); | const String& file_spec=params.as_string(0, FILE_NAME_MUST_BE_STRING); |
| // /a/some.tar.gz > some.tar | // /a/some.tar.gz > some.tar |
| int afterslash=lastposafter(file_spec, 0, "/", 1); | int afterslash=lastposafter(file_spec, 0, "/", 1); |
| int afterdot=lastposafter(file_spec, afterslash, ".", 1); | int afterdot=lastposafter(file_spec, afterslash, ".", 1); |
| r.write_assign_lang(file_spec.mid(afterslash, afterdot!=afterslash?afterdot-1:file_spec.length())); | r.write_assign_lang(file_spec.mid(afterslash, afterdot!=afterslash?afterdot-1:file_spec.length())); |
| } | } |
| static void _justext(Request& r, MethodParams& params) { | static void _justext(Request& r, MethodParams& params) { |
| const String& file_spec=params.as_string(0, "file name must be string"); | const String& file_spec=params.as_string(0, FILE_NAME_MUST_BE_STRING); |
| // /a/some.tar.gz > gz | // /a/some.tar.gz > gz |
| int afterdot=lastposafter(file_spec, 0, ".", 1); | int afterdot=lastposafter(file_spec, 0, ".", 1); |
| if(afterdot>0) | if(afterdot>0) |
| Line 706 static void _justext(Request& r, MethodP | Line 726 static void _justext(Request& r, MethodP |
| } | } |
| static void _fullpath(Request& r, MethodParams& params) { | static void _fullpath(Request& r, MethodParams& params) { |
| const String& file_spec=params.as_string(0, "file name must be string"); | const String& file_spec=params.as_string(0, FILE_NAME_MUST_BE_STRING); |
| const String* result; | const String* result; |
| if(file_spec.first_char()=='/') | if(file_spec.first_char()=='/') |
| result=&file_spec; | result=&file_spec; |
| Line 855 static void _base64(Request& r, MethodPa | Line 875 static void _base64(Request& r, MethodPa |
| } | } |
| } else { | } else { |
| // encode | // encode |
| const String& file_spec=params.as_string(0, "file name must be string"); | const String& file_spec=params.as_string(0, FILE_NAME_MUST_BE_STRING); |
| const char* encoded=pa_base64_encode(r.absolute(file_spec)); | const char* encoded=pa_base64_encode(r.absolute(file_spec)); |
| r.write_assign_lang(*new String(encoded, 0, true/*once ?param=base64(something) was needed*/)); | r.write_assign_lang(*new String(encoded, 0, true/*once ?param=base64(something) was needed*/)); |
| } | } |
| Line 866 static void _crc32(Request& r, MethodPar | Line 886 static void _crc32(Request& r, MethodPar |
| if(&r.get_self() == file_class) { | if(&r.get_self() == file_class) { |
| // ^file:crc32[file-name] | // ^file:crc32[file-name] |
| if(params.count()) { | if(params.count()) { |
| const String& file_spec=params.as_string(0, "file name must be string"); | const String& file_spec=params.as_string(0, FILE_NAME_MUST_BE_STRING); |
| crc32=pa_crc32(r.absolute(file_spec)); | crc32=pa_crc32(r.absolute(file_spec)); |
| } else { | } else { |
| throw Exception("parser.runtime", | throw Exception("parser.runtime", |
| Line 928 static void _md5(Request& r, MethodParam | Line 948 static void _md5(Request& r, MethodParam |
| if(&r.get_self() == file_class) { | if(&r.get_self() == file_class) { |
| // ^file:md5[file-name] | // ^file:md5[file-name] |
| if(params.count()) { | if(params.count()) { |
| const String& file_spec=params.as_string(0, "file name must be string"); | const String& file_spec=params.as_string(0, FILE_NAME_MUST_BE_STRING); |
| md5=pa_md5(r.absolute(file_spec)); | md5=pa_md5(r.absolute(file_spec)); |
| } else { | } else { |
| throw Exception("parser.runtime", | throw Exception("parser.runtime", |