--- parser3/src/classes/string.C 2019/11/13 22:05:48 1.241 +++ parser3/src/classes/string.C 2019/12/05 21:35:28 1.244 @@ -21,7 +21,7 @@ #include "pa_vregex.h" #include "pa_charsets.h" -volatile const char * IDENT_STRING_C="$Id: string.C,v 1.241 2019/11/13 22:05:48 moko Exp $"; +volatile const char * IDENT_STRING_C="$Id: string.C,v 1.244 2019/12/05 21:35:28 moko Exp $"; // class @@ -153,15 +153,15 @@ static void _bool(Request& r, MethodPara } static void _left(Request& r, MethodParams& params) { - ssize_t sn=params.as_int(0, "n must be int", r); + int sn=params.as_int(0, "n must be int", r); const String& string=GET_SELF(r, VString).string(); - r.write(sn<0 ? string : string.mid(r.charsets.source(), 0, (size_t)sn)); + r.write(sn<0 ? string : string.mid(r.charsets.source(), 0, sn)); } static void _right(Request& r, MethodParams& params) { - ssize_t sn=params.as_int(0, "n must be int", r); + int sn=params.as_int(0, "n must be int", r); if(sn>0){ - size_t n=(size_t)sn; + size_t n=sn; const String& string=GET_SELF(r, VString).string(); size_t length=string.length(r.charsets.source()); r.write(n 1 ? params.as_hash(1) : NULL); char* decoded=0; - size_t length=0; - - pa_base64_decode(cstr, strlen(cstr), decoded, length, options); + size_t length=pa_base64_decode(cstr, strlen(cstr), decoded, options); if(decoded && length){ - if(memchr((const char*)decoded, 0, length)) - throw Exception(PARSER_RUNTIME, 0, "Invalid \\x00 character found while decode to string. Decode it to file instead."); + if(memchr(decoded, 0, length)) + throw Exception(PARSER_RUNTIME, 0, "Invalid \\x00 character found while decoding to string. Decode to file instead."); fix_line_breaks(decoded, length); + if(length) r.write(*new String(decoded, String::L_TAINTED)); }