From 250a94e18614cec99218af2e4e9d379b9a61b476 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Wed, 25 May 2016 12:08:06 +0300 Subject: [PATCH 1/3] Changed: minor changes --HG-- branch : develop --- code/nel/src/gui/group_html.cpp | 63 ++------------------------------- 1 file changed, 2 insertions(+), 61 deletions(-) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 18aa3e1eb..6f6e25171 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -338,14 +338,7 @@ namespace NLGUI #ifdef LOG_DL nlwarning("Init Image Download"); #endif - /* - // Get current flag - int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); - // Turn on leak-checking bit - tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF; - // Set flag to the new value - _CrtSetDbgFlag( tmpFlag ); - */ + string pathName = "cache"; if ( ! CFile::isExists( pathName ) ) CFile::createDirectory( pathName ); @@ -628,32 +621,6 @@ namespace NLGUI curl_multi_cleanup(MultiCurl); } - /* - void dolibcurltest() - { - nlwarning("start libcurl test"); - - initImageDownload(); - - addImageDownload("http://www.ryzom.com/en/"); - addImageDownload("http://www.ryzom.com/fr/"); - addImageDownload("http://www.ryzom.com/de/"); - - do - { - checkImageDownload(); - nlwarning("continue to sleep"); - nlSleep(300); - } - while(RunningCurls); - - releaseImageDownload(); - - nlwarning("end libcurl test"); - } - */ - - class CGroupListAdaptor : public CInterfaceGroup { public: @@ -726,10 +693,6 @@ namespace NLGUI // Build a UTF8 string string inputString(buf, buf+len); - // inputString.resize (len); - // uint i; - // for (i=0; i<(uint)len; i++) - // inputString[i] = buf[i]; if (_ParsingLua && _TrustedDomain) { @@ -747,7 +710,6 @@ namespace NLGUI ucstring tmp; tmp.reserve(len); uint ucLen = (uint)inputUCString.size(); - //uint ucLenWithoutSpace = 0; for (uint i=0; iaddChild (buttonGroup); paragraphChange (); } - - // addButton (CCtrlTextButton::PushButton, name, normal, pushed.empty()?normal:pushed, over, - // globalColor, "html_submit_form", param.c_str(), tooltip); } else if (type == "text") { @@ -5829,7 +5771,6 @@ namespace NLGUI { std::string ret; sint32 number = Value; - bool upper = false; if (Type == "disc") { From 85051340e18513ec617c9a116d7aaa86ae350043 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Wed, 25 May 2016 12:08:08 +0300 Subject: [PATCH 2/3] Changed: Move addLink code to beginElement --HG-- branch : develop --- code/nel/include/nel/gui/group_html.h | 3 - code/nel/src/gui/group_html.cpp | 107 ++++++++----------------- code/nel/src/gui/group_html_parser.cpp | 5 -- 3 files changed, 33 insertions(+), 82 deletions(-) diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h index aecf5f855..8b8d63c79 100644 --- a/code/nel/include/nel/gui/group_html.h +++ b/code/nel/include/nel/gui/group_html.h @@ -281,9 +281,6 @@ namespace NLGUI // A new text block has been parsed virtual void addText (const char * buf, int len); - // A link has been parsed - virtual void addLink (uint element_number, const std::vector &present, const std::vector &value); - // A new begin HTML element has been parsed ( for exemple) virtual void beginElement (uint element_number, const std::vector &present, const std::vector &value); diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index 6f6e25171..fa53c2017 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -748,69 +748,6 @@ namespace NLGUI // *************************************************************************** - void CGroupHTML::addLink (uint element_number, const std::vector &present, const std::vector &value) - { - if (_Browsing) - { - if (element_number == HTML_A) - { - registerAnchorName(MY_HTML_A); - - // #fragment works with both ID and NAME so register both - if (present[MY_HTML_A_NAME] && value[MY_HTML_A_NAME]) - _AnchorName.push_back(value[MY_HTML_A_NAME]); - - if (present[MY_HTML_A_HREF] && value[MY_HTML_A_HREF]) - { - string suri = value[MY_HTML_A_HREF]; - if(suri.find("ah:") == 0) - { - if (_TrustedDomain) - _Link.push_back (suri); - else - _Link.push_back (""); - } - else if (_TrustedDomain && suri[0] == '#' && _LuaHrefHack) - { - // Direct url (hack for lua beginElement) - _Link.push_back (suri.substr(1)); - } - else - { - // convert href from "?key=val" into "http://domain.com/?key=val" - _Link.push_back(getAbsoluteUrl(suri)); - } - - for(uint8 i = MY_HTML_A_ACCESSKEY; i < MY_HTML_A_Z_ACTION_SHORTCUT; i++) - { - if (present[i] && value[i]) - { - string title = value[i]; - // nlinfo("key %d = %s", i, title.c_str()); - } - } - //nlinfo("key of TITLE is : %d", MY_HTML_A_Z_ACTION_PARAMS); - if (present[MY_HTML_A_Z_ACTION_PARAMS] && value[MY_HTML_A_Z_ACTION_PARAMS]) - { - string title = value[MY_HTML_A_Z_ACTION_PARAMS]; - _LinkTitle.push_back(title); - } - else - _LinkTitle.push_back(""); - } - else - { - _Link.push_back(""); - _LinkTitle.push_back(""); - } - - - } - } - } - - // *************************************************************************** - #define getCellsParameters(prefix,inherit) \ {\ CGroupHTML::CCellParams cellParams; \ @@ -1123,6 +1060,8 @@ namespace NLGUI break; case HTML_A: { + registerAnchorName(MY_HTML_A); + CStyleParams style; style.FontSize = getFontSize(); style.TextColor = LinkColor; @@ -1138,12 +1077,36 @@ namespace NLGUI _FontStrikeThrough.push_back(style.StrikeThrough); _GlobalColor.push_back(LinkColorGlobalColor); _A.push_back(true); + _Link.push_back (""); + _LinkTitle.push_back(""); + _LinkClass.push_back(""); + // #fragment works with both ID and NAME so register both + if (present[MY_HTML_A_NAME] && value[MY_HTML_A_NAME]) + _AnchorName.push_back(value[MY_HTML_A_NAME]); if (present[MY_HTML_A_TITLE] && value[MY_HTML_A_TITLE]) - _LinkTitle.push_back(value[MY_HTML_A_TITLE]); + _LinkTitle.back() = value[MY_HTML_A_TITLE]; if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS]) - _LinkClass.push_back(value[MY_HTML_A_CLASS]); - + _LinkClass.back() = value[MY_HTML_A_CLASS]; + if (present[MY_HTML_A_HREF] && value[MY_HTML_A_HREF]) + { + string suri = value[MY_HTML_A_HREF]; + if(suri.find("ah:") == 0) + { + if (_TrustedDomain) + _Link.back() = suri; + } + else if (_TrustedDomain && suri[0] == '#' && _LuaHrefHack) + { + // Direct url (hack for lua beginElement) + _Link.back() = suri.substr(1); + } + else + { + // convert href from "?key=val" into "http://domain.com/?key=val" + _Link.back() = getAbsoluteUrl(suri); + } + } } break; case HTML_DIV: @@ -5412,15 +5375,11 @@ namespace NLGUI value.insert(value.begin() + (uint)it.nextKey().toInteger(), buffer); } + // ingame lua scripts from browser are using url scheme + // reason unknown + _LuaHrefHack = true; beginElement(element_number, present, value); - if (element_number == HTML_A) - { - // ingame lua scripts from browser are using url scheme - // reason unknown - _LuaHrefHack = true; - addLink(element_number, present, value); - _LuaHrefHack = false; - } + _LuaHrefHack = false; return 0; } diff --git a/code/nel/src/gui/group_html_parser.cpp b/code/nel/src/gui/group_html_parser.cpp index de96a63ea..5f6873477 100644 --- a/code/nel/src/gui/group_html_parser.cpp +++ b/code/nel/src/gui/group_html_parser.cpp @@ -61,11 +61,6 @@ namespace NLGUI } } - if (element_number == HTML_A) - { - addLink(element_number, present, value); - } - beginElement(element_number, present, value); } else From 9ba0ac65ea497f568d9bf6dfe9aea925d830bcae Mon Sep 17 00:00:00 2001 From: Nimetu Date: Wed, 25 May 2016 12:08:12 +0300 Subject: [PATCH 3/3] Fixed: Send user-agent string and cookies with image request. --HG-- branch : develop --- code/nel/src/gui/group_html.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/nel/src/gui/group_html.cpp b/code/nel/src/gui/group_html.cpp index fa53c2017..c5fccd164 100644 --- a/code/nel/src/gui/group_html.cpp +++ b/code/nel/src/gui/group_html.cpp @@ -316,6 +316,11 @@ namespace NLGUI curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true); curl_easy_setopt(curl, CURLOPT_URL, finalUrl.c_str()); + std::string userAgent = options.appName + "/" + options.appVersion; + curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); + + sendCookies(curl, _DocumentDomain, _TrustedDomain); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);