From feeb972821e4c1ac84ef2f6d3713052df51ee7b9 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Tue, 15 Dec 2020 02:08:04 +0000 Subject: [PATCH] WebView 3.01: bugfixes (thanks Mihail Serebryakov and rgimad for reports), refactor URL parse git-svn-id: svn://kolibrios.org@8410 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/browser/TWB/TWB.c | 5 ++- programs/cmm/browser/WebView.c | 3 +- programs/cmm/lib/obj/http.h | 66 +++++++++++++++++----------------- 3 files changed, 35 insertions(+), 39 deletions(-) diff --git a/programs/cmm/browser/TWB/TWB.c b/programs/cmm/browser/TWB/TWB.c index b6a0528a4c..17a65fa884 100644 --- a/programs/cmm/browser/TWB/TWB.c +++ b/programs/cmm/browser/TWB/TWB.c @@ -189,7 +189,6 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ } for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;) { - //bukva = ESBYTE[bufpos]; switch (ESBYTE[bufpos]) { case 0x0a: @@ -212,8 +211,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ case '&': //  and so on for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (!__isWhite(ESBYTE[bufpos+j])) && (j<8); j++) { - bukva = ESBYTE[bufpos+j]; - chrcat(#unicode_symbol, bukva); + chrcat(#unicode_symbol, ESBYTE[bufpos+j]); } if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) { bufpos += j; @@ -228,6 +226,7 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ switch (ESBYTE[bufpos]) { case '!': case '/': + case '?': case 'a'...'z': case 'A'...'Z': goto _TAG; diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index e9b1e7d96e..20ce2313ce 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -41,7 +41,7 @@ // DATA // // // //===================================================// -char version[]="WebView 3 GOLD"; +char version[]="WebView 3.01"; #define DEFAULT_URL URL_SERVICE_HOMEPAGE @@ -593,7 +593,6 @@ bool EventClickAnchor() if (anchors.get_pos_by_name(aURL+1)!=-1) { WB1.list.first = anchors.get_pos_by_name(aURL+1); - //WB1.list.CheckDoesValuesOkey(); strcpy(#editURL, history.current()); strcat(#editURL, aURL); DrawOmnibox(); diff --git a/programs/cmm/lib/obj/http.h b/programs/cmm/lib/obj/http.h index 9cce208b9b..8dbbda4bd7 100644 --- a/programs/cmm/lib/obj/http.h +++ b/programs/cmm/lib/obj/http.h @@ -101,7 +101,7 @@ dword _http::get(dword _url) cur_url = _url; http_get stdcall (_url, 0, 0, #accept_language); transfer = EAX; - return transfer; + return EAX; } void _http::hfree() @@ -203,41 +203,39 @@ void _http::receive() while (i=strstr(new_URL, "&")) strcpy(i+1, i+5); - if (check_is_the_url_absolute(new_URL)) return orig_URL; + if (check_is_the_url_absolute(new_URL)) return new_URL; - IF (!strncmp(new_URL,"//", 2)) - { - strncpy(#newurl, "http:", URL_SIZE); - strncat(#newurl, new_URL, URL_SIZE); - strncpy(orig_URL, #newurl, URL_SIZE); - return orig_URL; + switch(ESBYTE[new_URL]) { + case '.': + new_URL++; + if (ESBYTE[new_URL] == '/') { + new_URL++; + } + else if (ESBYTE[new_URL] == '.') && (ESBYTE[new_URL+1] == '/') { + _GO_UP: + new_URL+=2; + newurl[strrchr(#newurl, '/')-1] = '\0'; + } + goto _DEFAULT; + case '?': + strchr(#newurl+8, '?'); //returns EAX + if (EAX) ESBYTE[EAX] = '\0'; + break; + case '/': + new_URL++; + if (ESBYTE[new_URL] == '/') { + strcpy(#newurl, "http:/"); + break; + } + EAX = strchr(#newurl+8, '/'); + if (EAX) ESBYTE[EAX] = '\0'; + default: + _DEFAULT: + EAX = strrchr(#newurl, '/'); + if (newurl[EAX-2]!='/') newurl[EAX] = '\0'; + if (!strncmp(new_URL,"../",3)) goto _GO_UP; + if (newurl[strlen(#newurl)-1]!='/') strncat(#newurl, "/", URL_SIZE); } - - IF (!strncmp(new_URL,"./", 2)) new_URL+=2; - - if (ESBYTE[new_URL] == '/') //remove everything after site domain name - { - i = strchr(#newurl+8, '/'); - if (i) ESBYTE[i]=0; - new_URL+=1; - } - - _CUT_ST_LEVEL_MARK: - - if (newurl[strrchr(#newurl, '/')-2]<>'/') - { - newurl[strrchr(#newurl, '/')] = 0x00; - } - - IF (!strncmp(new_URL,"../",3)) - { - new_URL+=3; - newurl[strrchr(#newurl, '/')-1] = 0x00; - goto _CUT_ST_LEVEL_MARK; - } - - if (newurl[strlen(#newurl)-1]<>'/') strncat(#newurl, "/", URL_SIZE); - strncat(#newurl, new_URL, URL_SIZE); strncpy(orig_URL, #newurl, URL_SIZE); return orig_URL;