From cd00029f0ebe23c5b3d77ce1697d193bf3a3f3e8 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Wed, 2 Dec 2020 14:21:06 +0000 Subject: [PATCH] WebView: small fixes git-svn-id: svn://kolibrios.org@8302 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 18 +++++++++++++----- programs/cmm/browser/WebView.c | 20 +++++++++++--------- programs/cmm/lib/strings.h | 15 +++++++++++++-- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index 8e0ac95023..5d4bac8c37 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -52,6 +52,7 @@ struct TWebBrowser { void ChangeEncoding(); void DrawPage(); char header[150]; + char redirect[URL_SIZE]; }; scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; @@ -137,6 +138,7 @@ void TWebBrowser::SetPageDefaults() stolbec = 0; line = 0; zoom = 1; + redirect = '\0'; //hold original buffer if (o_bufpointer) o_bufpointer=free(o_bufpointer); o_bufpointer = malloc(bufsize); @@ -532,16 +534,22 @@ void TWebBrowser::SetStyle() { draw_y += 10; return; } + if (tag.is("meta")) { + if (streq(tag.get_value_of("http-equiv="), "refresh")) && (value = tag.get_value_of("content=")) { + if (value = strstri(value, "url=")) strcpy(#redirect, value); + } + } if (custom_encoding == -1) && (tag.is("meta")) || (tag.is("?xml")) { if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding=")) { value += strrchr(value, '='); //search in content= + if (ESBYTE[value] == '"') value++; strlwr(value); - if (streq(value,"utf-8")) || (streq(value,"utf8")) ChangeEncoding(CH_UTF8); - else if (streq(value,"windows-1251")) || (streq(value,"windows1251")) ChangeEncoding(CH_CP1251); - else if (streq(value,"dos")) || (streq(value,"cp-866")) ChangeEncoding(CH_CP866); - else if (streq(value,"iso-8859-5")) || (streq(value,"iso8859-5")) ChangeEncoding(CH_ISO8859_5); - else if (streq(value,"koi8-r")) || (streq(value,"koi8-u")) ChangeEncoding(CH_KOI8); + if (streqrp(value,"utf-8")) || (streqrp(value,"utf8")) { ChangeEncoding(CH_UTF8); debugln("UTF"); } + else if (streqrp(value,"windows-1251")) || (streqrp(value,"windows1251")) ChangeEncoding(CH_CP1251); + else if (streqrp(value,"dos")) || (streqrp(value,"cp-866")) ChangeEncoding(CH_CP866); + else if (streqrp(value,"iso-8859-5")) || (streqrp(value,"iso8859-5")) ChangeEncoding(CH_ISO8859_5); + else if (streqrp(value,"koi8-r")) || (streqrp(value,"koi8-u")) ChangeEncoding(CH_KOI8); } return; } diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 17caaa2122..e15fd1be1d 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -32,7 +32,7 @@ char editbox_icons[] = FROM "res/editbox_icons.raw"; -char version[]="WebView 2.7"; +char version[]="WebView 2.7a"; #include "texts.h" #include "cache.h" @@ -238,7 +238,8 @@ void main() if (http.transfer <= 0) break; http.receive(); EventUpdateProgressBar(); - if (http.check_content_type()) && (!strncmp(#http.content_type,"application",11)) { + if (http.check_content_type()) // application || image + if (http.content_type[0] == 'a') || (http.content_type[0] == 'i') { EventOpenDownloader(history.current()); StopLoading(); history.back(); @@ -705,13 +706,6 @@ void EventClickLink(dword _target) } return; } - } else { - if (UrlExtIs(#new_url,".png")==true) || (UrlExtIs(#new_url,".jpg")==true) - || (UrlExtIs(#new_url,".zip")==true) || (UrlExtIs(#new_url,".kex")==true) || (UrlExtIs(#new_url,".pdf")==true) - || (UrlExtIs(#new_url,".7z")==true) { - EventOpenDownloader(#new_url); - return; - } } OpenPage(#new_url); } @@ -741,6 +735,14 @@ void LoadInternalPage(dword _bufdata, _in_bufsize){ DrawOmnibox(); } WB1.ParseHtml(_bufdata, _in_bufsize); + // REJECTED. Reason: infinite redirect at Google Results. + /* + if (WB1.redirect) { // + get_absolute_url(#WB1.redirect, history.current()); + history.back(); + OpenPage(#WB1.redirect); + } + */ DrawStatusBar(); DrawActiveTab(); if (source_mode) { diff --git a/programs/cmm/lib/strings.h b/programs/cmm/lib/strings.h index 06ac3414c3..ec40a9f38c 100644 --- a/programs/cmm/lib/strings.h +++ b/programs/cmm/lib/strings.h @@ -206,7 +206,7 @@ inline signed int strcmp(dword text1, text2) } -inline fastcall streq(ESI, EDI) +inline fastcall bool streq(ESI, EDI) { loop() { @@ -220,7 +220,18 @@ inline fastcall streq(ESI, EDI) ESI++; EDI++; } - return true; +} + +inline fastcall bool streqrp(ESI, EDI) //streq right part +{ + if(DSBYTE[ESI]==0) || (DSBYTE[EDI]==0) return false; + loop() + { + if(DSBYTE[EDI]==0) return true; + if(DSBYTE[ESI]!=DSBYTE[EDI]) return false; + ESI++; + EDI++; + } } inline fastcall void strcpy( EDI, ESI)