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

@@ -112,8 +112,12 @@ bool ssl = false;
}
// !! IMPROVE ME
// !! mozna zrobic jakas obsluge kiedy nie mozemy sie redirectnac, np gdy wystapil blad
// !! moze zwracac jakas wartosc?
/*
postfix will not be UrlEncoded
*/
void System::RedirectTo(const Item & item, const wchar_t * postfix)
{
PutUrlProto(config->use_ssl, cur->request->redirect_to);
@@ -137,6 +141,9 @@ void System::RedirectTo(const Item & item, const wchar_t * postfix)
/*
postfix will not be UrlEncoded
*/
void System::RedirectTo(long item_id, const wchar_t * postfix)
{
PutUrlProto(config->use_ssl, cur->request->redirect_to);
@@ -174,12 +181,16 @@ void System::RedirectTo(long item_id, const wchar_t * postfix)
}
void System::RedirectTo(const std::wstring & url)
/*
url will not be UrlEncoded
*/
void System::RedirectTo(const wchar_t * url)
{
PutUrlProto(config->use_ssl, cur->request->redirect_to);
cur->request->redirect_to += config->base_url;
if( !url.empty() && url[0] == '/' )
if( url[0] == '/' )
{
// absolute path
cur->request->redirect_to += url;
@@ -201,6 +212,19 @@ void System::RedirectTo(const std::wstring & url)
}
/*
url will not be UrlEncoded
*/
void System::RedirectTo(const std::wstring & url)
{
RedirectTo(url.c_str());
}
/*
params will be UrlEncoded
*/
void System::AddParams(const ParamTab & param_tab, std::wstring & str, bool clear_str)
{
if( clear_str )
@@ -209,19 +233,22 @@ void System::AddParams(const ParamTab & param_tab, std::wstring & str, bool clea
for(size_t i=0 ; i<param_tab.size() ; ++i)
{
str += '/';
str += param_tab[i].name;
UrlEncode(param_tab[i].name, str, false);
if( !param_tab[i].value.empty() )
{
str += ':';
str += param_tab[i].value;
UrlEncode(param_tab[i].value, str, false);
}
}
}
void System::RedirectWithFunctionAndParamsTo(const std::wstring & url)
/*
url will not be UrlEncoded
params will be UrlEncoded
*/
void System::RedirectWithFunctionAndParamsTo(const wchar_t * url)
{
RedirectTo(url);
@@ -229,12 +256,21 @@ void System::RedirectWithFunctionAndParamsTo(const std::wstring & url)
return;
cur->request->redirect_to += '/';
cur->request->redirect_to += cur->request->function->fun.url;
cur->request->redirect_to += cur->request->function->fun.url;
AddParams(cur->request->param_tab, cur->request->redirect_to, false);
}
/*
url will not be UrlEncoded
params will be UrlEncoded
*/
void System::RedirectWithFunctionAndParamsTo(const std::wstring & url)
{
RedirectWithFunctionAndParamsTo(url.c_str());
}
void System::RedirectToLastDir()
{
if( !cur->request->dir_tab.empty() )