|
|
| version 1.282, 2024/10/02 22:54:02 | version 1.288, 2024/11/10 20:33:21 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b file parser class. | Parser: @b file parser class. |
| Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) |
| Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> | Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru> |
| */ | */ |
| Line 19 | Line 19 |
| #include "pa_vdate.h" | #include "pa_vdate.h" |
| #include "pa_dir.h" | #include "pa_dir.h" |
| #include "pa_vtable.h" | #include "pa_vtable.h" |
| #include "pa_varray.h" | |
| #include "pa_charset.h" | #include "pa_charset.h" |
| #include "pa_charsets.h" | #include "pa_charsets.h" |
| #include "pa_sql_connection.h" | #include "pa_sql_connection.h" |
| Line 56 public: | Line 57 public: |
| } | } |
| }; | }; |
| Table file_list_table_template(new File_list_table_template_columns); | static Table &file_list_table_template(){ |
| static Table *singleton=NULL; | |
| if(singleton==NULL) | |
| singleton=new Table(new File_list_table_template_columns); | |
| return *singleton; | |
| } | |
| // class | // class |
| Line 465 static void pass_cgi_header_attribute( | Line 471 static void pass_cgi_header_attribute( |
| } | } |
| static void append_to_argv(Request& r, ArrayString& argv, const String* str){ | 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, r.connection(false), &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 | /// @todo fix `` in perl - they produced flipping consoles and no output to perl |
| Line 545 static void _exec_cgi(Request& r, Method | Line 550 static void _exec_cgi(Request& r, Method |
| for(size_t i=param_index; i<params.count(); i++) { | for(size_t i=param_index; i<params.count(); i++) { |
| Value& param=params.as_no_junction(i, PARAM_MUST_NOT_BE_CODE); | Value& param=params.as_no_junction(i, PARAM_MUST_NOT_BE_CODE); |
| if(param.is_defined()){ | if(const String *string=param.get_string()){ |
| if(param.is_string()){ | append_to_argv(r, argv, string); |
| append_to_argv(r, argv, param.get_string()); | } else if(Table* table=param.get_table()){ |
| } else { | for(size_t j=0; j<table->count(); j++) |
| Table* table=param.get_table(); | append_to_argv(r, argv, table->get(j)->get(0)); |
| if(table){ | } else if(VArray* array=dynamic_cast<VArray*>(¶m)){ |
| for(size_t j=0; j<table->count(); j++) | for(ArrayValue::Iterator i(array->array()); i; i.next()){ |
| append_to_argv(r, argv, table->get(j)->get(0)); | if(i.value()){ |
| } else { | const String *string=i.value()->get_string(); |
| throw Exception(PARSER_RUNTIME, 0, "param must be string or table"); | if(!string) |
| i.value()->bark("array element is '%s', it does not have string value"); | |
| append_to_argv(r, argv, string); | |
| } | } |
| } | } |
| } else { | |
| throw Exception(PARSER_RUNTIME, 0, "param must be string or table or array of strings"); | |
| } | |
| } | |
| // remove trailing empty arguments for backward compatibility | |
| for(ArrayString::ReverseIterator i(argv); i;){ | |
| if(i.prev()->is_empty()){ // here for correct i.index() | |
| argv.remove(i.index()); | |
| } else { | |
| break; | |
| } | } |
| } | } |
| } | } |
| Line 724 static void _list(Request& r, MethodPara | Line 742 static void _list(Request& r, MethodPara |
| const char* absolute_path_cstr=r.full_disk_path(relative_path.as_string()).taint_cstr(String::L_FILE_SPEC); | const char* absolute_path_cstr=r.full_disk_path(relative_path.as_string()).taint_cstr(String::L_FILE_SPEC); |
| Table::Action_options table_options; | Table::Action_options table_options; |
| Table& table=*new Table(file_list_table_template, table_options); | Table& table=*new Table(file_list_table_template(), table_options); |
| const int ovector_size=(1/*match*/)*3; | const int ovector_size=(1/*match*/)*3; |
| int ovector[ovector_size]; | int ovector[ovector_size]; |