added: to misc:

UrlEncode() for char->wstring
         UrlEncode() for wstring->wstring
removed: Request::redirect_url_encoded flag
         the Request::redirect_to string should always be url-encoded
changed: in UrnEncode()
         now characters like '#' and '/' are not allowed in an url
         (will be url-encoded)
         


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@807 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-02-19 00:59:08 +00:00
parent 1a51b1adc7
commit 97c7edafd6
7 changed files with 130 additions and 50 deletions

View File

@@ -630,12 +630,46 @@ time_t Time(const tm * par);
tm Time(time_t par);
void UrlEncode(const std::string & in, std::string & out, bool clear_out = true);
template<class StringType>
void UrlEncode(char c, StringType & out, bool clear_out = true)
{
char buffer[10];
size_t buflen = sizeof(buffer)/sizeof(char);
if( clear_out )
out.clear();
if( (c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') ||
c == '.' || c == ',' || c == '-' || c == '_' || c == '(' || c == ')' )
{
out += c;
}
else
{
Toa(static_cast<unsigned char>(c), buffer, buflen, 16);
out += '%';
if( buffer[1] == 0 )
out += '0'; // there is only one character in the buffer
for(size_t i=0 ; buffer[i] != 0 ; ++i)
out += buffer[i];
}
}
void UrlEncode(const char * in, std::string & out, bool clear_out = true);
void UrlEncode(const std::string & in, std::string & out, bool clear_out = true);
void UrlEncode(const wchar_t * in, std::string & out, bool clear_out = true);
void UrlEncode(const std::wstring & in, std::string & out, bool clear_out = true);
void UrlEncode(const wchar_t * in, std::wstring & out, bool clear_out = true);
void UrlEncode(const std::wstring & in, std::wstring & out, bool clear_out = true);
void QEncode(const std::wstring & in, std::string & out, bool clear = true);
void RemovePostFileTmp(PostFileTab & post_file_tab);