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:
38
core/misc.h
38
core/misc.h
@@ -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);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user