Diff for /parser3/src/classes/string.C between versions 1.261 and 1.264

version 1.261, 2024/12/06 23:20:04 version 1.264, 2025/12/15 23:07:29
Line 71  static void _length(Request& r, MethodPa Line 71  static void _length(Request& r, MethodPa
   
 static void _int(Request& r, MethodParams& params) {  static void _int(Request& r, MethodParams& params) {
         const String& self_string=GET_SELF(r, VString).string();          const String& self_string=GET_SELF(r, VString).string();
         int converted;  
   
         if(self_string.is_empty()) {          if(self_string.is_empty()) {
                 if(params.count()>0)                  if(params.count()>0)
                         converted=params.as_int(0, "default must be int", r); // (default)                          r.write(*new VInt(params.as_int(0, "default must be int", r))); // (default)
                 else                  else
                         throw Exception(PARSER_RUNTIME, 0, "unable to convert empty string without default specified");                          throw Exception(PARSER_RUNTIME, 0, "unable to convert empty string without default specified");
         } else {          } else {
                 try {                  try {
                         converted=self_string.as_int();                          r.write(*new VInt(self_string.as_int()));
                 } catch(...) { // convert problem                  } catch(...) { // convert problem
                         if(params.count()>0)                          if(params.count()>0)
                                 converted=params.as_int(0, "default must be int", r); // (default)                                  r.write(*new VInt(params.as_int(0, "default must be int", r))); // (default)
                         else                          else
                                 rethrow; // we have a problem when no default                                  rethrow; // we have a problem when no default
                 }                  }
         }          }
   
         r.write(*new VInt(converted));  
 }  }
   
 static void _double(Request& r, MethodParams& params) {  static void _double(Request& r, MethodParams& params) {
Line 690  static void _trim(Request& r, MethodPara Line 687  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 716  Base64Options base64_encode_options(Requ Line 707  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 792  static void _js_unescape(Request& r, Met Line 777  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();

Removed from v.1.261  
changed lines
  Added in v.1.264


E-mail: