Changeset 3151
- Timestamp:
- 2002-06-17T15:27:27+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/cgiutils.cpp
r2426 r3151 25 25 26 26 #include "cgiutils.h" 27 27 #include "gsdlunicode.h" 28 28 29 29 static unsigned short hexdigit (unsigned short c) { … … 57 57 58 58 // convert %xx and + to their appropriate equivalents 59 // IE 6.0 and later use "%u" followed by 4 hex digits... 59 60 void decode_cgi_arg (text_t &argstr) { 60 61 text_t::iterator in = argstr.begin(); … … 67 68 else if (*in == '%') { 68 69 unsigned short c = '%'; 69 in++; 70 if (in != end) { 71 c = hexdigit (*in); 72 in++; 70 ++in; 71 if (in != end) { // this is an encoding... 72 if (*in == 'u') { // convert %uHHHH to unicode then current encoding 73 // this assumes a short int is at least 16 bits... 74 ++in; 75 if (in != end) 76 c=hexdigit(*in++) << 12; 77 if (in != end) 78 c+=hexdigit(*in++) << 8; 79 if (in != end) 80 c+=hexdigit(*in++) << 4; 81 if (in != end) 82 c+=hexdigit(*in); 83 /* BAD!! The following assumes the interface is using utf-8. But 84 at this point we don't know what encoding we are using, unless 85 we can parse it out of the string we are currently decoding... */ 86 text_t uni=" "; 87 uni[0]=c; 88 text_t utf8=to_utf8(uni); 89 int last_byte=utf8.size()-1; 90 for (int i=0;i<last_byte;i++) 91 *out++ = utf8[i]; 92 c=utf8[last_byte]; 93 } else { // convert %HH to hex value 94 c = hexdigit (*in); 95 ++in; 96 if (in != end && c < 16) { // sanity check on the previous character 97 c = c*16 + hexdigit (*in); 98 } 99 } 73 100 } 74 if (in != end && c < 16) { // sanity check on the previous character75 c = c*16 + hexdigit (*in);76 }77 78 101 *out = c; 79 102 } else *out = *in;
Note:
See TracChangeset
for help on using the changeset viewer.