mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-30 07:35:59 +00:00
Changed: Remove legacy HTTPCurrentDomain variable
This commit is contained in:
parent
16b08bd66e
commit
b619ef1865
5 changed files with 37 additions and 33 deletions
|
@ -39,7 +39,6 @@ namespace NLGUI
|
||||||
class CGroupParagraph;
|
class CGroupParagraph;
|
||||||
|
|
||||||
extern std::string CurrentCookie;
|
extern std::string CurrentCookie;
|
||||||
extern std::string HTTPCurrentDomain;
|
|
||||||
|
|
||||||
// HTML group
|
// HTML group
|
||||||
/**
|
/**
|
||||||
|
@ -376,6 +375,7 @@ namespace NLGUI
|
||||||
std::string _URL;
|
std::string _URL;
|
||||||
// Current URL
|
// Current URL
|
||||||
std::string _DocumentUrl;
|
std::string _DocumentUrl;
|
||||||
|
std::string _DocumentDomain;
|
||||||
// Valid base href was found
|
// Valid base href was found
|
||||||
bool _IgnoreBaseUrlTag;
|
bool _IgnoreBaseUrlTag;
|
||||||
// Fragment from loading url
|
// Fragment from loading url
|
||||||
|
|
|
@ -52,6 +52,7 @@ namespace NLGUI
|
||||||
public:
|
public:
|
||||||
std::string scheme;
|
std::string scheme;
|
||||||
std::string authority;
|
std::string authority;
|
||||||
|
std::string host;
|
||||||
std::string path;
|
std::string path;
|
||||||
std::string query;
|
std::string query;
|
||||||
std::string hash;
|
std::string hash;
|
||||||
|
|
|
@ -506,7 +506,7 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
receiveCookies(_CurlWWW->Request, HTTPCurrentDomain, _TrustedDomain);
|
receiveCookies(_CurlWWW->Request, _DocumentDomain, _TrustedDomain);
|
||||||
|
|
||||||
// redirect, get the location and try browse again
|
// redirect, get the location and try browse again
|
||||||
// we cant use curl redirection because 'addHTTPGetParams()' must be called on new destination
|
// we cant use curl redirection because 'addHTTPGetParams()' must be called on new destination
|
||||||
|
@ -533,7 +533,7 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
receiveCookies(_CurlWWW->Request, HTTPCurrentDomain, _TrustedDomain);
|
receiveCookies(_CurlWWW->Request, _DocumentDomain, _TrustedDomain);
|
||||||
|
|
||||||
_RedirectsRemaining = DEFAULT_RYZOM_REDIRECT_LIMIT;
|
_RedirectsRemaining = DEFAULT_RYZOM_REDIRECT_LIMIT;
|
||||||
|
|
||||||
|
@ -2548,6 +2548,7 @@ namespace NLGUI
|
||||||
_SelectOption = false;
|
_SelectOption = false;
|
||||||
_GroupListAdaptor = NULL;
|
_GroupListAdaptor = NULL;
|
||||||
_DocumentUrl = "";
|
_DocumentUrl = "";
|
||||||
|
_DocumentDomain = "";
|
||||||
_UrlFragment.clear();
|
_UrlFragment.clear();
|
||||||
_RefreshUrl.clear();
|
_RefreshUrl.clear();
|
||||||
_NextRefreshTime = 0.0;
|
_NextRefreshTime = 0.0;
|
||||||
|
@ -4657,9 +4658,12 @@ namespace NLGUI
|
||||||
string finalUrl;
|
string finalUrl;
|
||||||
bool isLocal = lookupLocalFile (finalUrl, _URL.c_str(), true);
|
bool isLocal = lookupLocalFile (finalUrl, _URL.c_str(), true);
|
||||||
|
|
||||||
// Save new url
|
|
||||||
_URL = finalUrl;
|
_URL = finalUrl;
|
||||||
|
|
||||||
|
CUrlParser uri (_URL);
|
||||||
|
_TrustedDomain = isTrustedDomain(uri.host);
|
||||||
|
_DocumentDomain = uri.host;
|
||||||
|
|
||||||
// file is probably from bnp (ingame help)
|
// file is probably from bnp (ingame help)
|
||||||
if (isLocal)
|
if (isLocal)
|
||||||
{
|
{
|
||||||
|
@ -4667,8 +4671,6 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_TrustedDomain = isTrustedDomain(setCurrentDomain(finalUrl));
|
|
||||||
|
|
||||||
SFormFields formfields;
|
SFormFields formfields;
|
||||||
if (_PostNextTime)
|
if (_PostNextTime)
|
||||||
{
|
{
|
||||||
|
@ -4704,9 +4706,11 @@ namespace NLGUI
|
||||||
// Ref the form
|
// Ref the form
|
||||||
CForm &form = _Forms[_PostFormId];
|
CForm &form = _Forms[_PostFormId];
|
||||||
|
|
||||||
// Save new url
|
|
||||||
_URL = form.Action;
|
_URL = form.Action;
|
||||||
_TrustedDomain = isTrustedDomain(setCurrentDomain(_URL));
|
|
||||||
|
CUrlParser uri(_URL);
|
||||||
|
_TrustedDomain = isTrustedDomain(uri.host);
|
||||||
|
_DocumentDomain = uri.host;
|
||||||
|
|
||||||
for (i=0; i<form.Entries.size(); i++)
|
for (i=0; i<form.Entries.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -4814,6 +4818,7 @@ namespace NLGUI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_TrustedDomain = true;
|
_TrustedDomain = true;
|
||||||
|
_DocumentDomain = "localhost";
|
||||||
|
|
||||||
// Stop previous browse, remove content
|
// Stop previous browse, remove content
|
||||||
stopBrowse ();
|
stopBrowse ();
|
||||||
|
@ -4899,7 +4904,7 @@ namespace NLGUI
|
||||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str());
|
curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str());
|
||||||
|
|
||||||
// Cookies
|
// Cookies
|
||||||
sendCookies(curl, HTTPCurrentDomain, _TrustedDomain);
|
sendCookies(curl, _DocumentDomain, _TrustedDomain);
|
||||||
|
|
||||||
// Referer
|
// Referer
|
||||||
if (!referer.empty())
|
if (!referer.empty())
|
||||||
|
@ -4983,9 +4988,6 @@ namespace NLGUI
|
||||||
nlwarning("(%s) HTML download finished, content length %d, type '%s', code %d", _Id.c_str(), content.size(), type.c_str(), code);
|
nlwarning("(%s) HTML download finished, content length %d, type '%s', code %d", _Id.c_str(), content.size(), type.c_str(), code);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// set trusted domain for parsing
|
|
||||||
_TrustedDomain = isTrustedDomain(setCurrentDomain(_URL));
|
|
||||||
|
|
||||||
// create <html> markup for image downloads
|
// create <html> markup for image downloads
|
||||||
if (type.find("image/") == 0 && content.size() > 0)
|
if (type.find("image/") == 0 && content.size() > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,6 @@ namespace NLGUI
|
||||||
|
|
||||||
/// store all cookies we receive and resent them depending of the domain
|
/// store all cookies we receive and resent them depending of the domain
|
||||||
static std::map<std::string, std::map<std::string, std::string> > HTTPCookies;
|
static std::map<std::string, std::map<std::string, std::string> > HTTPCookies;
|
||||||
std::string HTTPCurrentDomain; // The current domain that will be used to get which cookies to send
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
||||||
|
@ -332,24 +331,6 @@ namespace NLGUI
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set current HTTPCurrentDomain for cookie selection, return new domain
|
|
||||||
const std::string &setCurrentDomain(const std::string &uri)
|
|
||||||
{
|
|
||||||
if (uri.find("http://") == 0)
|
|
||||||
HTTPCurrentDomain = uri.substr(7, uri.find("/", 7) - 7);
|
|
||||||
else
|
|
||||||
if (uri.find("https://") == 0)
|
|
||||||
HTTPCurrentDomain = uri.substr(8, uri.find("/", 8) - 8);
|
|
||||||
else
|
|
||||||
if (uri.find("//") == 0)
|
|
||||||
HTTPCurrentDomain = uri.substr(2, uri.find("/", 2) - 2);
|
|
||||||
else
|
|
||||||
if (uri.find("/") != std::string::npos)
|
|
||||||
HTTPCurrentDomain = uri.substr(0, uri.find("/") - 1);
|
|
||||||
|
|
||||||
return HTTPCurrentDomain;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update HTTPCookies list
|
// update HTTPCookies list
|
||||||
static void receiveCookie(const char *nsformat, const std::string &domain, bool trusted)
|
static void receiveCookie(const char *nsformat, const std::string &domain, bool trusted)
|
||||||
{
|
{
|
||||||
|
@ -371,6 +352,9 @@ namespace NLGUI
|
||||||
chunks[0] = chunks[0].substr(10);
|
chunks[0] = chunks[0].substr(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure domain is lowercase
|
||||||
|
chunks[0] = toLower(chunks[0]);
|
||||||
|
|
||||||
if (chunks[0] != domain && chunks[0] != std::string("." + domain))
|
if (chunks[0] != domain && chunks[0] != std::string("." + domain))
|
||||||
{
|
{
|
||||||
// cookie is for different domain
|
// cookie is for different domain
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <string>
|
#include "nel/misc/common.h"
|
||||||
#include "nel/misc/types_nl.h"
|
|
||||||
#include "nel/gui/url_parser.h"
|
#include "nel/gui/url_parser.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -72,6 +71,24 @@ namespace NLGUI
|
||||||
uri = uri.substr(pos);
|
uri = uri.substr(pos);
|
||||||
else
|
else
|
||||||
uri.clear();
|
uri.clear();
|
||||||
|
|
||||||
|
// strip empty port from authority
|
||||||
|
if (authority.find_last_of(":") == authority.length() - 1)
|
||||||
|
authority = authority.substr(0, authority.length() - 1);
|
||||||
|
|
||||||
|
// extract host from user:pass@host:port
|
||||||
|
pos = authority.find("@");
|
||||||
|
if (pos != npos)
|
||||||
|
host = authority.substr(pos + 1);
|
||||||
|
else
|
||||||
|
host = authority.substr(2);
|
||||||
|
|
||||||
|
// case-insensitive
|
||||||
|
host = NLMISC::toLower(host);
|
||||||
|
|
||||||
|
pos = host.find(":");
|
||||||
|
if (pos != npos)
|
||||||
|
host = host.substr(0, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// scan for query
|
// scan for query
|
||||||
|
|
Loading…
Reference in a new issue