|
|
| version 1.122.2.1, 2004/01/22 08:27:20 | version 1.127, 2004/02/06 09:25:22 |
|---|---|
| Line 5 | Line 5 |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| static const char* IDENT_UNTAINT_C="$Date$"; | static const char * const IDENT_UNTAINT_C="$Date$"; |
| #include "pa_string.h" | #include "pa_string.h" |
| Line 98 inline bool need_http_header_encode(unsi | Line 98 inline bool need_http_header_encode(unsi |
| return need_uri_encode(c); | return need_uri_encode(c); |
| } | } |
| // | |
| static const char* String_Untaint_lang_name[]={ | |
| "U", ///< zero value handy for hash lookup @see untaint_lang_name2enum | |
| "C", ///< clean | |
| "T", ///< tainted, untaint language as assigned later | |
| // untaint languages. assigned by ^untaint[lang]{...} | |
| "P", | |
| /**< | |
| leave language built into string being appended. | |
| just a flag, that value not stored | |
| */ | |
| "A", ///< leave all characters intact | |
| "F", ///< file specification | |
| "H", ///< ext in HTTP response header | |
| "M", ///< text in mail header | |
| "URI", ///< text in uri | |
| "T", ///< ^table:set body | |
| "SQL", ///< ^table:sql body | |
| "JS", ///< JavaScript code | |
| "XML", ///< ^dom:set xml | |
| "HTML" ///< HTML code (for editing) | |
| }; | |
| // String | // String |
| /* | /* |
| HTTP-header = field-name ":" [ field-value ] CRLF | HTTP-header = field-name ":" [ field-value ] CRLF |
| field-name = token | field-name = token |
| Line 268 inline bool mail_header_char_valid_withi | Line 242 inline bool mail_header_char_valid_withi |
| || strchr("!*+-/", c); | || strchr("!*+-/", c); |
| } | } |
| inline bool addr_spec_soon(const char *src) { | inline bool addr_spec_soon(const char *src) { |
| for(char c; c=*src; src++) | for(char c; (c=*src); src++) |
| if(c=='<') | if(c=='<') |
| return true; | return true; |
| else if(!(c==' ' || c=='\t')) | else if(!(c==' ' || c=='\t')) |
| Line 284 inline bool addr_spec_soon(const char *s | Line 258 inline bool addr_spec_soon(const char *s |
| inline bool mail_header_nonspace_char(char c) { | inline bool mail_header_nonspace_char(char c) { |
| return c != 0x20; | return c != 0x20; |
| } | } |
| inline void ec_append(CORD_ec& result, bool& optimize, bool& whitespace, CORD_pos pos, size_t size) { | inline void ec_append(CORD_ec& result, bool& optimize, bool& whitespace, CORD_pos pos, size_t size) { |
| while(size--) { | while(size--) { |
| CORD_ec_append(result, CORD_pos_fetch(pos)); | CORD_ec_append(result, CORD_pos_fetch(pos)); |
| Line 292 inline void ec_append(CORD_ec& result, b | Line 267 inline void ec_append(CORD_ec& result, b |
| } | } |
| inline void pa_CORD_pos_advance(CORD_pos pos, size_t n) { | inline void pa_CORD_pos_advance(CORD_pos pos, size_t n) { |
| while(true) { | while(true) { |
| size_t avail=CORD_pos_chars_left(pos); | long avail=CORD_pos_chars_left(pos); |
| if(avail==0) { | if(avail<=0) { |
| CORD_next(pos); | CORD_next(pos); |
| if(!--n) | if(!--n) |
| break; | break; |
| } else if(avail<n) { | } else if((size_t)avail<n) { |
| CORD_pos_advance(pos, avail); | CORD_pos_advance(pos, avail); |
| n-=avail; | n-=avail; |
| } else { // avail>=n | } else { // avail>=n |
| Line 373 int cstr_to_string_body_block(char alang | Line 348 int cstr_to_string_body_block(char alang |
| info->charsets->client()); | info->charsets->client()); |
| char c; | char c; |
| for(const char* src=output.str; c=*src++; ) | for(const char* src=output.str; (c=*src++); ) |
| encode(need_uri_encode, '%', c); | encode(need_uri_encode, '%', c); |
| } | } |
| break; | break; |
| Line 400 int cstr_to_string_body_block(char alang | Line 375 int cstr_to_string_body_block(char alang |
| bool email=false; | bool email=false; |
| uchar c; | uchar c; |
| for(const char* src=mail_ptr; c=(uchar)*src++; ) { | for(const char* src=mail_ptr; (c=(uchar)*src++); ) { |
| //RFC + An 'encoded-word' MUST NOT appear in any portion of an 'addr-spec'. | //RFC + An 'encoded-word' MUST NOT appear in any portion of an 'addr-spec'. |
| if(to_quoted_printable && (c==',' || addr_spec_soon(src) || c == '"')) { | if(to_quoted_printable && (c==',' || addr_spec_soon(src) || c == '"')) { |
| email=c=='<'; | email=c=='<'; |
| Line 482 int cstr_to_string_body_block(char alang | Line 457 int cstr_to_string_body_block(char alang |
| }); | }); |
| break; | break; |
| default: | default: |
| assert(!"should never"); | SAPI::abort("unknown untaint language #%d", |
| SAPI::die("unknown untaint language #%d", | |
| static_cast<int>(to_lang)); // should never | static_cast<int>(to_lang)); // should never |
| break; // never | break; // never |
| } | } |