WebView 3.14: fix critical regression with file download

git-svn-id: svn://kolibrios.org@8444 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-12-18 12:55:55 +00:00
parent becbfa3198
commit 408000706a
4 changed files with 47 additions and 47 deletions

View File

@ -165,21 +165,6 @@ void TWebBrowser::SetPageDefaults()
} }
} }
//============================================================================================ //============================================================================================
void TWebBrowser::AddCharToTheLine(unsigned char _char)
{
dword line_len;
if (_char<=15) _char=' ';
line_len = strlen(#line);
if (!style.pre) && (_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();
}
//============================================================================================
void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
char unicode_symbol[10]; char unicode_symbol[10];
dword j; dword j;
@ -282,6 +267,21 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
} }
} }
//============================================================================================ //============================================================================================
void TWebBrowser::AddCharToTheLine(unsigned char _char)
{
dword line_len;
if (_char<=15) _char=' ';
line_len = strlen(#line);
if (!style.pre) && (_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();
}
//============================================================================================
bool TWebBrowser::CheckForLineBreak() bool TWebBrowser::CheckForLineBreak()
{ {
int line_break_pos; int line_break_pos;
@ -309,17 +309,6 @@ bool TWebBrowser::CheckForLineBreak()
return true; return true;
} }
//============================================================================================ //============================================================================================
void TWebBrowser::ChangeEncoding(int _new_encoding)
{
if (cur_encoding == _new_encoding) return;
cur_encoding = _new_encoding;
bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer);
if (header) {
ChangeCharset(cur_encoding, "CP866", #header);
DrawTitle(#header);
}
}
//============================================================================================
void TWebBrowser::NewLine() void TWebBrowser::NewLine()
{ {
static int empty_line=0; static int empty_line=0;
@ -342,6 +331,17 @@ void TWebBrowser::NewLine()
stolbec += style.tag_list.level * 5; stolbec += style.tag_list.level * 5;
} }
//============================================================================================ //============================================================================================
void TWebBrowser::ChangeEncoding(int _new_encoding)
{
if (cur_encoding == _new_encoding) return;
cur_encoding = _new_encoding;
bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer);
if (header) {
ChangeCharset(cur_encoding, "CP866", #header);
DrawTitle(#header);
}
}
//============================================================================================
scroll_bar scroll_wv = scroll_bar scroll_wv =
{ 15,NULL,NULL,NULL,0,2,NULL, { 15,NULL,NULL,NULL,0,2,NULL,
0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; 0,0,0xeeeeee,0xBBBbbb,0xeeeeee};

View File

@ -142,14 +142,14 @@ dword _tag::get_next_param(dword ps, pe)
//find ATTR end //find ATTR end
while (pe > ps) && (ESBYTE[pe] != '=') pe--; while (pe > ps) && (ESBYTE[pe] != '=') pe--;
ESBYTE[pe+1] = '\0'; ESBYTE[pe] = '\0';
} }
else else
{ {
//find VAL start and copy //find VAL start and copy
while (pe > ps) && (ESBYTE[pe] != '=') pe--; while (pe > ps) && (ESBYTE[pe] != '=') pe--;
pe++; strlcpy(#val, pe+1, sizeof(val)-1);
strlcpy(#val, pe, sizeof(val)-1); ESBYTE[pe] = '\0';
//already have ATTR end //already have ATTR end
} }

View File

@ -1,6 +1,6 @@
void TWebBrowser::SetStyle() void TWebBrowser::SetStyle()
{ {
if (tag.get_value_of("name=")) || (tag.get_value_of("id=")) { if (tag.get_value_of("name")) || (tag.get_value_of("id")) {
anchors.add(tag.value, draw_y); anchors.add(tag.value, draw_y);
if (anchors.current) && (streq(tag.value, #anchors.current+1)) { if (anchors.current) && (streq(tag.value, #anchors.current+1)) {
list.first = draw_y; list.first = draw_y;
@ -77,8 +77,8 @@ void TWebBrowser::tag_font()
style.bg_color = page_bg; style.bg_color = page_bg;
if (tag.opened) if (tag.opened)
{ {
if (tag.get_value_of("bg=")) style.bg_color = GetColor(tag.value); if (tag.get_value_of("bg")) style.bg_color = GetColor(tag.value);
if (tag.get_value_of("color=")) { if (tag.get_value_of("color")) {
text_colors.add(GetColor(tag.value)); text_colors.add(GetColor(tag.value));
} else { } else {
text_colors.add(text_colors.get_last()); text_colors.add(text_colors.get_last());
@ -96,7 +96,7 @@ void TWebBrowser::tag_div()
void TWebBrowser::tag_iframe() void TWebBrowser::tag_iframe()
{ {
if (tag.get_value_of("src=")) { if (tag.get_value_of("src")) {
NewLine(); NewLine();
strcpy(#line, "IFRAME: "); strcpy(#line, "IFRAME: ");
Paint(); Paint();
@ -114,7 +114,7 @@ void TWebBrowser::tag_a()
{ {
if (tag.opened) if (tag.opened)
{ {
if (tag.get_value_of("href=")) && (!strstr(tag.value,"javascript:")) if (tag.get_value_of("href")) && (!strstr(tag.value,"javascript:"))
{ {
link = true; link = true;
links.add_link(tag.value); links.add_link(tag.value);
@ -127,8 +127,8 @@ void TWebBrowser::tag_a()
void TWebBrowser::tag_meta_xml() void TWebBrowser::tag_meta_xml()
{ {
if (custom_encoding == -1) if (tag.get_value_of("charset=")) if (custom_encoding == -1) if (tag.get_value_of("charset"))
|| (tag.get_value_of("content=")) || (tag.get_value_of("encoding=")) || (tag.get_value_of("content")) || (tag.get_value_of("encoding"))
{ {
EDX = strrchr(tag.value, '=') + tag.value; //search in content= EDX = strrchr(tag.value, '=') + tag.value; //search in content=
if (ESBYTE[EDX] == '"') EDX++; if (ESBYTE[EDX] == '"') EDX++;
@ -139,8 +139,8 @@ void TWebBrowser::tag_meta_xml()
else if (streqrp(EDX,"iso-8859-5")) || (streqrp(EDX,"iso8859-5")) ChangeEncoding(CH_ISO8859_5); else if (streqrp(EDX,"iso-8859-5")) || (streqrp(EDX,"iso8859-5")) ChangeEncoding(CH_ISO8859_5);
else if (streqrp(EDX,"koi8-r")) || (streqrp(EDX,"koi8-u")) ChangeEncoding(CH_KOI8); else if (streqrp(EDX,"koi8-r")) || (streqrp(EDX,"koi8-u")) ChangeEncoding(CH_KOI8);
} }
if (streq(tag.get_value_of("http-equiv="), "refresh")) && (tag.get_value_of("content=")) { if (streq(tag.get_value_of("http-equiv"), "refresh")) && (tag.get_value_of("content")) {
if (tag.value = strstri(tag.value, "url=")) strcpy(#redirect, tag.value); if (tag.value = strstri(tag.value, "url")) strcpy(#redirect, tag.value);
} }
} }
@ -187,7 +187,7 @@ void TWebBrowser::tag_li()
void TWebBrowser::tag_hr() void TWebBrowser::tag_hr()
{ {
EAX = 0x999999; EAX = 0x999999;
if (tag.get_value_of("color=")) GetColor(tag.value); if (tag.get_value_of("color")) GetColor(tag.value);
$push eax; $push eax;
NewLine(); NewLine();
$pop edi; $pop edi;
@ -201,10 +201,10 @@ void TWebBrowser::tag_hr()
void TWebBrowser::tag_body() void TWebBrowser::tag_body()
{ {
t_body = tag.opened; t_body = tag.opened;
if (tag.get_value_of("link=")) link_color_default = GetColor(tag.value); if (tag.get_value_of("link")) link_color_default = GetColor(tag.value);
if (tag.get_value_of("alink=")) link_color_active = GetColor(tag.value); if (tag.get_value_of("alink")) link_color_active = GetColor(tag.value);
if (tag.get_value_of("text=")) text_colors.set(0, GetColor(tag.value)); if (tag.get_value_of("text")) text_colors.set(0, GetColor(tag.value));
if (tag.get_value_of("bgcolor=")) { if (tag.get_value_of("bgcolor")) {
style.bg_color = page_bg = GetColor(tag.value); style.bg_color = page_bg = GetColor(tag.value);
canvas.Fill(0, page_bg); canvas.Fill(0, page_bg);
} }
@ -260,7 +260,7 @@ void TWebBrowser::tag_img()
dword cur_img; dword cur_img;
int img_x, img_y, img_w, img_h; int img_x, img_y, img_w, img_h;
if (!tag.get_value_of("src=")) goto NOIMG; if (!tag.get_value_of("src")) goto NOIMG;
if (streqrp(tag.value, "data:")) { if (streqrp(tag.value, "data:")) {
if (!strstr(tag.value, "base64,")) goto NOIMG; if (!strstr(tag.value, "base64,")) goto NOIMG;
@ -334,7 +334,7 @@ IMGOK:
return; return;
NOIMG: NOIMG:
if (tag.get_value_of("title=")) || (tag.get_value_of("alt=")) { if (tag.get_value_of("title")) || (tag.get_value_of("alt")) {
strncpy(#img_path, tag.value, sizeof(line)-3); strncpy(#img_path, tag.value, sizeof(line)-3);
sprintf(#line, "[%s]", #img_path); sprintf(#line, "[%s]", #img_path);
} else { } else {

View File

@ -41,7 +41,7 @@
// DATA // // DATA //
// // // //
//===================================================// //===================================================//
char version[]="WebView 3.12"; char version[]="WebView 3.14";
#define DEFAULT_URL URL_SERVICE_HOMEPAGE #define DEFAULT_URL URL_SERVICE_HOMEPAGE
@ -904,7 +904,7 @@ void CheckContentType()
EventDownloadAndOpenImage(http.cur_url); EventDownloadAndOpenImage(http.cur_url);
StopLoading(); StopLoading();
}if (content_type[0] == 'a') { }if (content_type[0] == 'a') {
EventOpenDownloader(history.current()); EventOpenDownloader(http.cur_url);
StopLoading(); StopLoading();
} }
} }