changed: using PT::ToLower instead of ToSmall
using PT::ToUpper instead of ToCapital using PT::EqualNoCase instead of EqualNoCase git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1112 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
aa58faf145
commit
436a198c36
|
@ -49,6 +49,7 @@
|
|||
#include "misc.h"
|
||||
#include "functions/functions.h"
|
||||
#include "utf8/utf8.h"
|
||||
#include "convert/convert.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
|
@ -836,7 +837,7 @@ bool App::SaveEnvHTTPVariable(const char * env)
|
|||
|
||||
for( ; env[i] != 0 && env[i] != '=' && i < Request::INPUT_HEADER_NAME_MAX_LENGTH ; ++i)
|
||||
{
|
||||
header_name[i] = ToSmall(env[i]);
|
||||
header_name[i] = PT::ToLower(env[i]);
|
||||
}
|
||||
|
||||
header_name[i] = 0;
|
||||
|
@ -883,7 +884,7 @@ void App::ReadEnvRemoteIP()
|
|||
{
|
||||
http_header = L"HTTP_";
|
||||
http_header += config.proxy_ip_header;
|
||||
ToCapital(http_header);
|
||||
PT::ToUpper(http_header);
|
||||
|
||||
PT::WideToUTF8(http_header, http_header_8bit);
|
||||
v = FCGX_GetParam(http_header_8bit.c_str(), fcgi_request.envp);
|
||||
|
@ -909,16 +910,16 @@ void App::CheckRequestMethod()
|
|||
|
||||
if( !cur.request->env_request_method.empty() )
|
||||
{
|
||||
if( ToSmall(cur.request->env_request_method[0]) == 'g' )
|
||||
if( PT::ToLower(cur.request->env_request_method[0]) == 'g' )
|
||||
cur.request->method = Request::get;
|
||||
else
|
||||
if( ToSmall(cur.request->env_request_method[0]) == 'p' )
|
||||
if( PT::ToLower(cur.request->env_request_method[0]) == 'p' )
|
||||
cur.request->method = Request::post;
|
||||
else
|
||||
if( ToSmall(cur.request->env_request_method[0]) == 'h' )
|
||||
if( PT::ToLower(cur.request->env_request_method[0]) == 'h' )
|
||||
cur.request->method = Request::head;
|
||||
else
|
||||
if( ToSmall(cur.request->env_request_method[0]) == 'd' )
|
||||
if( PT::ToLower(cur.request->env_request_method[0]) == 'd' )
|
||||
cur.request->method = Request::delete_;
|
||||
}
|
||||
}
|
||||
|
@ -934,7 +935,7 @@ void App::CheckSSL()
|
|||
if( config.assume_connection_is_through_ssl )
|
||||
cur.request->using_ssl = true;
|
||||
else
|
||||
if( EqualNoCase(cur.request->env_https.c_str(), L"on") )
|
||||
if( PT::EqualNoCase(cur.request->env_https.c_str(), L"on") )
|
||||
cur.request->using_ssl = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "misc.h"
|
||||
#include "log.h"
|
||||
#include "templates/templates.h"
|
||||
#include "convert/convert.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
|
@ -331,7 +332,7 @@ void CorrectUrlOnlyAllowedChar(std::wstring & url)
|
|||
{
|
||||
CorrectUrlDots(url);
|
||||
CorrectUrlChars(url);
|
||||
ToSmall(url);
|
||||
PT::ToLower(url);
|
||||
Trim(url, '_');
|
||||
|
||||
if( url.empty() || url == L"." )
|
||||
|
@ -788,43 +789,6 @@ void Overwrite(std::wstring & str)
|
|||
|
||||
|
||||
|
||||
wchar_t ToSmall(wchar_t c)
|
||||
{
|
||||
if( c>='A' && c<='Z' )
|
||||
c = c - 'A' + 'a';
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void ToSmall(std::wstring & s)
|
||||
{
|
||||
std::wstring::size_type i;
|
||||
|
||||
for(i=0 ; i<s.size() ; ++i)
|
||||
s[i] = ToSmall(s[i]);
|
||||
}
|
||||
|
||||
|
||||
wchar_t ToCapital(wchar_t c)
|
||||
{
|
||||
if( c>='a' && c<='z' )
|
||||
c = c - 'a' + 'A';
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void ToCapital(std::wstring & s)
|
||||
{
|
||||
std::wstring::size_type i;
|
||||
|
||||
for(i=0 ; i<s.size() ; ++i)
|
||||
s[i] = ToCapital(s[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool IsEmailCorrectChar(wchar_t c)
|
||||
{
|
||||
bool correct = false;
|
||||
|
@ -1231,31 +1195,31 @@ int SelectFileType(const wchar_t * file_name)
|
|||
|
||||
// as an image we're using only those types which can be rendered
|
||||
// by a web browser
|
||||
if( EqualNoCase(ext, L"jpg") ||
|
||||
EqualNoCase(ext, L"jpeg") ||
|
||||
EqualNoCase(ext, L"jpe") ||
|
||||
EqualNoCase(ext, L"pic") ||
|
||||
EqualNoCase(ext, L"tga") ||
|
||||
EqualNoCase(ext, L"gif") ||
|
||||
EqualNoCase(ext, L"bmp") ||
|
||||
EqualNoCase(ext, L"png") )
|
||||
if( PT::EqualNoCase(ext, L"jpg") ||
|
||||
PT::EqualNoCase(ext, L"jpeg") ||
|
||||
PT::EqualNoCase(ext, L"jpe") ||
|
||||
PT::EqualNoCase(ext, L"pic") ||
|
||||
PT::EqualNoCase(ext, L"tga") ||
|
||||
PT::EqualNoCase(ext, L"gif") ||
|
||||
PT::EqualNoCase(ext, L"bmp") ||
|
||||
PT::EqualNoCase(ext, L"png") )
|
||||
return WINIX_ITEM_FILETYPE_IMAGE;
|
||||
|
||||
if( EqualNoCase(ext, L"pdf") ||
|
||||
EqualNoCase(ext, L"doc") ||
|
||||
EqualNoCase(ext, L"xls") ||
|
||||
EqualNoCase(ext, L"txt") ||
|
||||
EqualNoCase(ext, L"ods") ||
|
||||
EqualNoCase(ext, L"odt") )
|
||||
if( PT::EqualNoCase(ext, L"pdf") ||
|
||||
PT::EqualNoCase(ext, L"doc") ||
|
||||
PT::EqualNoCase(ext, L"xls") ||
|
||||
PT::EqualNoCase(ext, L"txt") ||
|
||||
PT::EqualNoCase(ext, L"ods") ||
|
||||
PT::EqualNoCase(ext, L"odt") )
|
||||
return WINIX_ITEM_FILETYPE_DOCUMENT;
|
||||
|
||||
if( EqualNoCase(ext, L"avi") ||
|
||||
EqualNoCase(ext, L"mp4") ||
|
||||
EqualNoCase(ext, L"flv") ||
|
||||
EqualNoCase(ext, L"mpg") ||
|
||||
EqualNoCase(ext, L"mpeg") ||
|
||||
EqualNoCase(ext, L"mkv") ||
|
||||
EqualNoCase(ext, L"wmv") )
|
||||
if( PT::EqualNoCase(ext, L"avi") ||
|
||||
PT::EqualNoCase(ext, L"mp4") ||
|
||||
PT::EqualNoCase(ext, L"flv") ||
|
||||
PT::EqualNoCase(ext, L"mpg") ||
|
||||
PT::EqualNoCase(ext, L"mpeg") ||
|
||||
PT::EqualNoCase(ext, L"mkv") ||
|
||||
PT::EqualNoCase(ext, L"wmv") )
|
||||
return WINIX_ITEM_FILETYPE_VIDEO;
|
||||
|
||||
return WINIX_ITEM_FILETYPE_UNKNOWN;
|
||||
|
|
|
@ -378,14 +378,6 @@ bool was_comma = false;
|
|||
|
||||
|
||||
|
||||
wchar_t ToSmall(wchar_t c);
|
||||
void ToSmall(std::wstring & s);
|
||||
|
||||
wchar_t ToCapital(wchar_t c);
|
||||
void ToCapital(std::wstring & s);
|
||||
|
||||
|
||||
|
||||
|
||||
template<class StringType1, class StringType2>
|
||||
bool IsSubStringp(const StringType1 * short_str, const StringType2 * long_str)
|
||||
|
@ -420,7 +412,7 @@ bool IsSubString(const StringType1 & short_str, const StringType2 & long_str)
|
|||
template<class StringType1, class StringType2>
|
||||
bool IsSubStringNoCasep(const StringType1 * short_str, const StringType2 * long_str)
|
||||
{
|
||||
while( *short_str && *long_str && ToSmall(*short_str) == ToSmall(*long_str) )
|
||||
while( *short_str && *long_str && PT::ToLower(*short_str) == PT::ToLower(*long_str) )
|
||||
{
|
||||
++short_str;
|
||||
++long_str;
|
||||
|
@ -471,30 +463,6 @@ bool Equal(const StringType1 & str1, const StringType2 & str2)
|
|||
|
||||
|
||||
|
||||
template<class StringType1, class StringType2>
|
||||
bool EqualNoCase(const StringType1 * str1, const StringType2 * str2)
|
||||
{
|
||||
while( *str1 && *str2 && ToSmall(*str1) == ToSmall(*str2) )
|
||||
{
|
||||
++str1;
|
||||
++str2;
|
||||
}
|
||||
|
||||
if( *str1 == 0 && *str2 == 0 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType1, class StringType2>
|
||||
bool EqualNoCase(const StringType1 & str1, const StringType2 & str2)
|
||||
{
|
||||
return EqualNoCase(str1.c_str(), str2.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
looking for 'look_for' string in 'buf' and replacing it with 'replace'
|
||||
'replace' can be empty (so only 'look_for' will be deleted)
|
||||
|
|
Loading…
Reference in New Issue