diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index d7d2e93fba..573ad15ab6 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -62,6 +62,7 @@ char attr[1200]; char val[4096]; char anchor[256]=0; +#include "..\TWB\absolute_url.h" #include "..\TWB\links.h" #include "..\TWB\colors.h" #include "..\TWB\unicode_tags.h" @@ -352,8 +353,7 @@ void TWebBrowser::SetStyle() { return; } if (istag("br")) { NewLine(); return; } - if (istag("tr")) { if (opened) { NewLine(); strcat(#line, "| "); } return; } - if (istag("td")) || (istag("th")) { if (!opened) strcat(#line, " | "); return; } + if (istag("tr")) { if (opened) NewLine(); return; } if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } if (istag("i")) || (istag("em")) || (istag("subtitle")) { style.i=opened; return; } if (istag("u")) || (istag("ins")) { style.u=opened; return;} diff --git a/programs/cmm/TWB/absolute_url.h b/programs/cmm/TWB/absolute_url.h new file mode 100644 index 0000000000..9c6c50c389 --- /dev/null +++ b/programs/cmm/TWB/absolute_url.h @@ -0,0 +1,70 @@ + +int UrlIsAbsolute(dword in) +{ + if(!strncmp(in,"http:",5)) return true; + if(!strncmp(in,"https:",6)) return true; + if(!strncmp(in,"mailto:",7)) return true; + if(!strncmp(in,"ftp:",4)) return true; + if(!strncmp(in,"WebView:",8)) return true; + if(!strncmp(in,"/sys/",5)) return true; + if(!strncmp(in,"/hd/",4)) return true; + if(!strncmp(in,"/fd/",4)) return true; + if(!strncmp(in,"/rd/",4)) return true; + if(!strncmp(in,"/tmp/",5)) return true; + if(!strncmp(in,"/cd/",4)) return true; + if(!strncmp(in,"/bd/",4)) return true; + if(!strncmp(in,"/usbhd/",7)) return true; + if(!strncmp(in,"/kolibrios/",11)) return true; + return false; +} + +void GetAbsoluteURL(dword in_URL) +{ + int i; + dword orig_URL = in_URL; + char newurl[sizeof(URL)]; + + while (i=strstr(in_URL, "&")) + { + strcpy(i+1, i+5); + } + + if (UrlIsAbsolute(in_URL)) return; + + IF (!strcmpn(in_URL,"./", 2)) in_URL+=2; + if (!http_transfer) + { + strcpy(#newurl, History.current()); + } + else + { + strcpy(#newurl, History.items.get(History.active-2)); + } + + if (ESBYTE[in_URL] == '/') //remove everything after site domain name + { + i = strchr(#newurl+8, '/'); + if (i) ESBYTE[i]=0; + in_URL+=1; + } + + _CUT_ST_LEVEL_MARK: + + if (newurl[strrchr(#newurl, '/')-2]<>'/') + { + newurl[strrchr(#newurl, '/')] = 0x00; + } + + IF (!strncmp(in_URL,"../",3)) + { + in_URL+=3; + newurl[strrchr(#newurl, '/')-1] = 0x00; + goto _CUT_ST_LEVEL_MARK; + } + + if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/"); + + strcat(#newurl, in_URL); + strcpy(orig_URL, #newurl); +} + diff --git a/programs/cmm/TWB/img_cache.h b/programs/cmm/TWB/img_cache.h index 112647b140..ee50fa6449 100644 --- a/programs/cmm/TWB/img_cache.h +++ b/programs/cmm/TWB/img_cache.h @@ -44,7 +44,7 @@ void ImageCache::Images(int left1, top1, width1) if (isattr("src=")) { strcpy(#img_path, #val); - PageLinks.GetAbsoluteURL(#img_path); + GetAbsoluteURL(#img_path); cur_pic = GetImage(#img_path); } if (isattr("alt=")) diff --git a/programs/cmm/TWB/links.h b/programs/cmm/TWB/links.h index 2e44c4b8cb..8871adc72a 100644 --- a/programs/cmm/TWB/links.h +++ b/programs/cmm/TWB/links.h @@ -20,8 +20,6 @@ struct LinksArray { void AddText(); dword GetURL(); void Clear(); - void GetAbsoluteURL(); - int UrlAbsolute(); } PageLinks; void LinksArray::AddLink(dword lpath, int link_x, link_y) @@ -98,68 +96,3 @@ void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col) active = -1; } } - -int LinksArray::UrlAbsolute(dword in_URL) -{ - if(!strncmp(in_URL,"http:",5)) return 1; - if(!strncmp(in_URL,"https:",6)) return 1; - if(!strncmp(in_URL,"mailto:",7)) return 1; - if(!strncmp(in_URL,"ftp:",4)) return 1; - if(!strncmp(in_URL,"WebView:",8)) return 1; - if(!strncmp(in_URL,"/sys/",5)) return 1; - if(!strncmp(in_URL,"/hd/",4)) return 1; - if(!strncmp(in_URL,"/fd/",4)) return 1; - if(!strncmp(in_URL,"/rd/",4)) return 1; - if(!strncmp(in_URL,"/tmp/",5)) return 1; - if(!strncmp(in_URL,"/cd/",4)) return 1; - if(!strncmp(in_URL,"/bd/",4)) return 1; - if(!strncmp(in_URL,"/usbhd/",7)) return 1; - if(!strncmp(in_URL,"/kolibrios/",11)) return 1; - return 0; -} - -void LinksArray::GetAbsoluteURL(dword in_URL) -{ - int i; - dword orig_URL = in_URL; - char newurl[sizeof(URL)]; - - if (UrlAbsolute(in_URL)) return; - - IF (!strcmpn(in_URL,"./", 2)) in_URL+=2; - if (!http_transfer) - { - strcpy(#newurl, History.current()); - } - else - { - strcpy(#newurl, History.items.get(History.active-2)); - } - - if (ESBYTE[in_URL] == '/') //remove everything after site domain name - { - i = strchr(#newurl+8, '/'); - if (i) ESBYTE[i]=0; - in_URL+=1; - } - - _CUT_ST_LEVEL_MARK: - - if (newurl[strrchr(#newurl, '/')-2]<>'/') - { - newurl[strrchr(#newurl, '/')] = 0x00; - } - - IF (!strncmp(in_URL,"../",3)) - { - in_URL+=3; - newurl[strrchr(#newurl, '/')-1] = 0x00; - goto _CUT_ST_LEVEL_MARK; - } - - if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/"); - - strcat(#newurl, in_URL); - strcpy(orig_URL, #newurl); -} - diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 18a8d0177b..16a2b2b7d8 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -29,14 +29,14 @@ char homepage[] = FROM "html\\homepage.htm"; #ifdef LANG_RUS - char version[]=" Текстовый браузер 1.40"; + char version[]=" Текстовый браузер 1.41"; ?define IMAGES_CACHE_CLEARED "Кэш картинок очищен" ?define T_LAST_SLIDE "Это последний слайд" char loading[] = "Загрузка страницы...
"; char page_not_found[] = FROM "html\page_not_found_ru.htm"; char accept_language[]= "Accept-Language: ru\n"; #else - char version[]=" Text-based Browser 1.40"; + char version[]=" Text-based Browser 1.41"; ?define IMAGES_CACHE_CLEARED "Images cache cleared" ?define T_LAST_SLIDE "This slide is the last" char loading[] = "Loading...
"; @@ -217,7 +217,7 @@ void main() { http_free stdcall (http_transfer); http_transfer=0; - PageLinks.GetAbsoluteURL(#URL); + GetAbsoluteURL(#URL); History.back(); strcpy(#editURL, #URL); DrawEditBox(); @@ -518,7 +518,7 @@ void ClickLink() URL[strrchr(#URL, '#')-1] = 0x00; } - PageLinks.GetAbsoluteURL(#URL); + GetAbsoluteURL(#URL); if (UrlExtIs(".png")==1) || (UrlExtIs(".gif")==1) || (UrlExtIs(".jpg")==1) || (UrlExtIs(".zip")==1) || (UrlExtIs(".kex")==1) || (UrlExtIs(".7z")==1) || (UrlExtIs("netcfg")==1)