Diff for /parser3/src/classes/string.C between versions 1.257 and 1.263

version 1.257, 2024/10/05 03:38:14 version 1.263, 2025/10/05 19:41:27
Line 1 Line 1
 /** @file  /** @file
         Parser: @b string parser class.          Parser: @b string 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 209  static void _pos(Request& r, MethodParam Line 209  static void _pos(Request& r, MethodParam
 struct Split_action_info {  struct Split_action_info {
         const String& src;          const String& src;
         ArrayString &result;          ArrayString &result;
           Split_action_info(const String& s, ArrayString& r) : src(s), result(r) {}
 };  };
   
 static void split_action(Table& , ArrayString* row, int prestart, int prefinish, int poststart, int postfinish, void *info) {  static void split_action(Table& , ArrayString* row, int prestart, int prefinish, int poststart, int postfinish, void *info) {
Line 226  static void split_list(Value& delim_valu Line 227  static void split_list(Value& delim_valu
                 vregex->study();                  vregex->study();
   
                 int matches_count=0;                  int matches_count=0;
                 Split_action_info ai = { string, result };                  Split_action_info ai(string, result);
   
                 string.match(vregex, split_action, &ai, matches_count);                  string.match(vregex, split_action, &ai, matches_count);
         } else          } else
Line 640  static void _save(Request& r, MethodPara Line 641  static void _save(Request& r, MethodPara
                 }                  }
         }          }
   
         const String& file_name=params.as_string(file_name_index, FILE_NAME_MUST_BE_STRING);          const String& file_name=params.as_file_name(file_name_index);
         const String& src=GET_SELF(r, VString).string();          const String& src=GET_SELF(r, VString).string();
   
         String::Body sbody=src.cstr_to_string_body_untaint(String::L_AS_IS, r.connection(false), &r.charsets);          String::Body sbody=src.cstr_to_string_body_untaint(String::L_AS_IS, r.connection(false), &r.charsets);
Line 689  static void _trim(Request& r, MethodPara Line 690  static void _trim(Request& r, MethodPara
 Base64Options base64_encode_options(Request& r, HashStringValue* options) {  Base64Options base64_encode_options(Request& r, HashStringValue* options) {
         Base64Options result;          Base64Options result;
         if(options) {          if(options) {
                 int valid_options=0;  
                 for(HashStringValue::Iterator i(*options); i; i.next()) {                  for(HashStringValue::Iterator i(*options); i; i.next()) {
                         String::Body key=i.key();                          String::Body key=i.key();
                         Value* value=i.value();                          Value* value=i.value();
                         if(key == "pad") {                          if(key == "pad") {
                                 result.pad=r.process(*value).as_bool();                                  result.pad=r.process(*value).as_bool();
                                 valid_options++;  
                         } else if(key == "wrap") {                          } else if(key == "wrap") {
                                 result.wrap=r.process(*value).as_bool();                                  result.wrap=r.process(*value).as_bool();
                                 valid_options++;  
                         } else if(key == "url-safe") {                          } else if(key == "url-safe") {
                                 if(r.process(*value).as_bool())                                  if(r.process(*value).as_bool())
                                         result.set_url_safe_abc();                                          result.set_url_safe_abc();
                                 valid_options++;                          } else
                         }                                  throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION);
                 }                  }
   
                 if(valid_options != options->count())  
                         throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION);  
         }          }
         return result;          return result;
 }  }
Line 715  Base64Options base64_encode_options(Requ Line 710  Base64Options base64_encode_options(Requ
 Base64Options base64_decode_options(Request& r, HashStringValue* options) {  Base64Options base64_decode_options(Request& r, HashStringValue* options) {
         Base64Options result;          Base64Options result;
         if(options) {          if(options) {
                 int valid_options=0;  
                 for(HashStringValue::Iterator i(*options); i; i.next() ) {                  for(HashStringValue::Iterator i(*options); i; i.next() ) {
                         String::Body key=i.key();                          String::Body key=i.key();
                         Value* value=i.value();                          Value* value=i.value();
                         if(key == "pad") {                          if(key == "pad") {
                                 result.pad=r.process(*value).as_bool();                                  result.pad=r.process(*value).as_bool();
                                 valid_options++;  
                         } else if(key == "strict") {                          } else if(key == "strict") {
                                 result.strict=r.process(*value).as_bool();                                  result.strict=r.process(*value).as_bool();
                                 valid_options++;  
                         } else if(key == "url-safe") {                          } else if(key == "url-safe") {
                                 if(r.process(*value).as_bool())                                  if(r.process(*value).as_bool())
                                         result.set_url_safe_abc();                                          result.set_url_safe_abc();
                                 valid_options++;                          } else
                         }                                  throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION);
                 }                  }
   
                 if(valid_options != options->count())  
                         throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION);  
         }          }
         return result;          return result;
 }  }
Line 791  static void _js_unescape(Request& r, Met Line 780  static void _js_unescape(Request& r, Met
 }  }
   
 static void _unescape(Request& r, MethodParams& params){  static void _unescape(Request& r, MethodParams& params){
         const String& mode=params.as_string(0, MODE_MUST_NOT_BE_CODE);          const String& mode=params.as_string(0, MODE_MUST_BE_STRING);
         const String& src=params.as_string(1, PARAMETER_MUST_BE_STRING);          const String& src=params.as_string(1, PARAMETER_MUST_BE_STRING);
   
         Charset* from_charset=&r.charsets.client();          Charset* from_charset=&r.charsets.client();
Line 813  static void _unescape(Request& r, Method Line 802  static void _unescape(Request& r, Method
         } else if(mode==UNESCAPE_MODE_URI){          } else if(mode==UNESCAPE_MODE_URI){
                 mode_js=false;                  mode_js=false;
         } else {          } else {
                 throw Exception(PARSER_RUNTIME, &mode, "is invalid mode, must be either '" UNESCAPE_MODE_JS "' or '" UNESCAPE_MODE_URI "'");                  throw Exception(PARSER_RUNTIME, &mode, "is an invalid mode, must be either '" UNESCAPE_MODE_JS "' or '" UNESCAPE_MODE_URI "'");
         }          }
   
         const char* unescaped=unescape_chars(src.cstr(), src.length(), from_charset, mode_js);          const char* unescaped=unescape_chars(src.cstr(), src.length(), from_charset, mode_js);

Removed from v.1.257  
changed lines
  Added in v.1.263


E-mail: