From 294679216a4021c1e1c640f66a6c0599abea698d Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Tue, 8 Dec 2020 23:32:54 +0000 Subject: [PATCH] WebView: fix 2 cases of crash, no space on the link start git-svn-id: svn://kolibrios.org@8350 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/browser/TWB/TWB.c | 8 +++++--- programs/cmm/browser/TWB/special.h | 1 + programs/cmm/browser/WebView.c | 2 +- programs/cmm/lib/draw_buf.h | 11 ++++------- programs/cmm/lib/obj/http.h | 12 ++++++------ 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/programs/cmm/browser/TWB/TWB.c b/programs/cmm/browser/TWB/TWB.c index 7a31e0ccb4..04e2e37aaa 100644 --- a/programs/cmm/browser/TWB/TWB.c +++ b/programs/cmm/browser/TWB/TWB.c @@ -158,6 +158,7 @@ void TWebBrowser::AddCharToTheLine(unsigned char _char) { if (line[line_len-1]==' ') return; //no double spaces if (!stolbec) && (!line) return; //no paces at the beginning of the line + if (link) && (line_len==0) return; } if (line_len < sizeof(line)) chrcat(#line, _char); CheckForLineBreak(); @@ -468,13 +469,14 @@ void TWebBrowser::SetStyle() { img.url.add(#img_path); - if (img.w.get_last() / 6 + 1 + stolbec > list.column_max) { + if (img.w.get_last() / 6 + stolbec > list.column_max) { NewLine(); } img.x.add(stolbec*list.font_w+3); img.y.add(draw_y); - stolbec += img.w.get_last() / 6 + 1; + stolbec += img.w.get_last() / 6; + if (stolbec > list.column_max) NewLine(); if (img.h.get_last() > list.item_h) { draw_y += img.h.get_last() - list.item_h; @@ -488,7 +490,6 @@ void TWebBrowser::SetStyle() { img.h.get_last(), 0); - //debugval(img.url.get_last(), img.y.get_last()); return; } else { @@ -511,6 +512,7 @@ void TWebBrowser::SetStyle() { if (!line) { if (!strncmp(#img_path, "data:", 5)) img_path=0; replace_char(#img_path, '?', NULL, strlen(#img_path)); + img_path[sizeof(line)-3] = '\0'; //prevent overflow in sprintf sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); line[50]= NULL; } diff --git a/programs/cmm/browser/TWB/special.h b/programs/cmm/browser/TWB/special.h index 3ec4f7c4a6..3bb8fcd321 100644 --- a/programs/cmm/browser/TWB/special.h +++ b/programs/cmm/browser/TWB/special.h @@ -34,6 +34,7 @@ char *unicode_symbols[]={ "#1031", "\244", "#8211", "-", +"#8212", "-", "#8217", "'", "#8220", "\"", "#8222", "\"", "ldquo", "\"", diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 3a30fcae84..0e0983da11 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -42,7 +42,7 @@ // DATA // // // //===================================================// -char version[]="WebView 2.8 BETA 2"; +char version[]="WebView 2.8 BETA 3"; #define DEFAULT_URL URL_SERVICE_HOMEPAGE diff --git a/programs/cmm/lib/draw_buf.h b/programs/cmm/lib/draw_buf.h index 3ac25e4dac..0152e299ba 100644 --- a/programs/cmm/lib/draw_buf.h +++ b/programs/cmm/lib/draw_buf.h @@ -25,11 +25,8 @@ struct DrawBufer { }; char draw_buf_not_enaught_ram[] = -"'DrawBufer needs more memory than currenly available. -Application could be unstable. - -Requested size: %i Mb -Free RAM: %i Mb' -E"; +"'DrawBufer requested %i MB more memory than the system has. +Application could be unstable.' -E"; bool DrawBufer::Init(dword i_bufx, i_bufy, i_bufw, i_bufh) { @@ -189,8 +186,8 @@ void DrawBufer::IncreaseBufSize() } free_ram_size = GetFreeRAM() * 1024; - if (alloc_size >= free_ram_size) { - sprintf(#error_str, #draw_buf_not_enaught_ram, alloc_size/1048576, free_ram_size/1048576); + if (alloc_size > free_ram_size) { + sprintf(#error_str, #draw_buf_not_enaught_ram, alloc_size - free_ram_size/1048576); notify(#error_str); } } diff --git a/programs/cmm/lib/obj/http.h b/programs/cmm/lib/obj/http.h index 87e7c536e1..9cce208b9b 100644 --- a/programs/cmm/lib/obj/http.h +++ b/programs/cmm/lib/obj/http.h @@ -207,9 +207,9 @@ void _http::receive() IF (!strncmp(new_URL,"//", 2)) { - strcpy(#newurl, "http:"); - strcat(#newurl, new_URL); - strcpy(orig_URL, #newurl); + strncpy(#newurl, "http:", URL_SIZE); + strncat(#newurl, new_URL, URL_SIZE); + strncpy(orig_URL, #newurl, URL_SIZE); return orig_URL; } @@ -236,10 +236,10 @@ void _http::receive() goto _CUT_ST_LEVEL_MARK; } - if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/"); + if (newurl[strlen(#newurl)-1]<>'/') strncat(#newurl, "/", URL_SIZE); - strcat(#newurl, new_URL); - strcpy(orig_URL, #newurl); + strncat(#newurl, new_URL, URL_SIZE); + strncpy(orig_URL, #newurl, URL_SIZE); return orig_URL; }