--- parser3/src/include/pa_string.h 2009/06/23 10:05:09 1.188 +++ parser3/src/include/pa_string.h 2009/07/07 12:13:28 1.192 @@ -8,7 +8,7 @@ #ifndef PA_STRING_H #define PA_STRING_H -static const char * const IDENT_STRING_H="$Date: 2009/06/23 10:05:09 $"; +static const char * const IDENT_STRING_H="$Date: 2009/07/07 12:13:28 $"; // includes #include "pa_types.h" @@ -100,14 +100,15 @@ public: L_FILE_SPEC='F', ///< file specification L_HTTP_HEADER='h', ///< text in HTTP response header L_MAIL_HEADER='m', ///< text in mail header - L_URI='U', ///< text in uri - L_SQL='Q', ///< ^table:sql body - L_JS='J', ///< JavaScript code - L_XML='X', ///< ^dom:set xml - L_HTML='H', ///< HTML code - L_REGEX='R', ///< RegEx expression + L_URI='U', ///< text in uri + L_SQL='Q', ///< ^table:sql body + L_JS='J', ///< JavaScript code + L_XML='X', ///< ^dom:set xml + L_HTML='H', ///< HTML code + L_REGEX='R', ///< RegEx expression L_HTTP_COOKIE='C', ///< cookies encoded as %uXXXX for compartibility with js functions encode/decode - L_FILE_POST='f', ///temporary escaping zero-char + L_FILE_POST='f', ///< temporary escaping zero-char + L_PARSER_CODE='p', ///< ^process body // READ WARNING ABOVE BEFORE ADDING ANYTHING L_OPTIMIZE_BIT = 0x80 ///< flag, requiring cstr whitespace optimization }; @@ -513,22 +514,34 @@ public: size_t length() const { return body.length(); } size_t length(Charset& charset) const; - /// convert to CORD. if 'lang' known, forcing 'lang' to it - Body cstr_to_string_body(Language lang=L_AS_IS, - SQL_Connection* connection=0, - const Request_charsets *charsets=0) const; - - /// convert to constant C string. if 'lang' known, forcing 'lang' to it - const char* cstr(Language lang=L_AS_IS, - SQL_Connection* connection=0, - const Request_charsets *charsets=0) const { - return cstr_to_string_body(lang, connection, charsets).cstr(); + /// convert to CORD forcing lang tainting + Body cstr_to_string_body_taint(Language lang, SQL_Connection* connection=0, const Request_charsets *charsets=0) const; + /// convert to CORD with tainting dirty to lang + Body cstr_to_string_body_untaint(Language lang, SQL_Connection* connection=0, const Request_charsets *charsets=0) const; + + /// + const char* cstr() const { + return body.cstr(); } - /// convert to Modifiable C string. if 'lang' known, forcing 'lang' to it - char *cstrm(Language lang=L_AS_IS, - SQL_Connection* connection=0, - const Request_charsets *charsets=0) const { - return cstr_to_string_body(lang, connection, charsets).cstrm(); + /// + char* cstrm() const { + return body.cstrm(); + } + + /// convert to constant C string forcing lang tainting + const char* taint_cstr(Language lang, SQL_Connection* connection=0, const Request_charsets *charsets=0) const { + return cstr_to_string_body_taint(lang, connection, charsets).cstr(); + } + char *taint_cstrm(Language lang, SQL_Connection* connection=0, const Request_charsets *charsets=0) const { + return cstr_to_string_body_taint(lang, connection, charsets).cstrm(); + } + + /// convert to constant C string with tainting dirty to lang + const char* untaint_cstr(Language lang, SQL_Connection* connection=0, const Request_charsets *charsets=0) const { + return cstr_to_string_body_untaint(lang, connection, charsets).cstr(); + } + char *untaint_cstrm(Language lang, SQL_Connection* connection=0, const Request_charsets *charsets=0) const { + return cstr_to_string_body_untaint(lang, connection, charsets).cstrm(); } /// puts pieces to buf Cm serialize(size_t prolog_size) const;