HTMLv: 0.99.72: fix processing URLs which starts from '/', handle errors on wrong site URL

git-svn-id: svn://kolibrios.org@4646 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2014-03-15 10:23:06 +00:00
parent bddab0d593
commit 99f718a31d
3 changed files with 60 additions and 19 deletions

View File

@ -116,7 +116,7 @@ void TWebBrowser::GetNewUrl(){
if (URL[0] == '/') if (URL[0] == '/')
{ {
i = strchr(#newurl+8, '/'); i = strchr(#newurl+8, '/');
newurl[i+7]=0; if (i>0) newurl[i+7]=0;
strcpy(#URL, #URL+1); strcpy(#URL, #URL+1);
} }
@ -142,12 +142,19 @@ void TWebBrowser::GetNewUrl(){
void BufEncode(int set_new_encoding) void BufEncode(int set_new_encoding)
{ {
int bufpointer_realsize;
cur_encoding = set_new_encoding; cur_encoding = set_new_encoding;
if (o_bufpointer==0) if (o_bufpointer==0)
{ {
debugi(bufsize); bufpointer_realsize = strlen(bufpointer);
bufsize = strlen(bufpointer); if (bufpointer_realsize > bufsize)
debugi(bufsize); {
debug("bufsize: ");
debugi(bufsize);
debug("bufpointer_realsize: ");
debugi(bufpointer_realsize);
bufsize = bufpointer_realsize;
}
o_bufpointer = malloc(bufsize); o_bufpointer = malloc(bufsize);
strcpy(o_bufpointer, bufpointer); strcpy(o_bufpointer, bufpointer);
} }
@ -412,6 +419,10 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
DrawBuf.Fill(bg_color); DrawBuf.Fill(bg_color);
} }
} while(GetNextParam()); } while(GetNextParam());
if (opened)
{
if (cur_encoding==_DEFAULT) BufEncode(_UTF); //if no encoding specified it would be UTF
}
return; return;
} }
@ -630,7 +641,7 @@ void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) meta_encoding = _KOI; if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) meta_encoding = _KOI;
if (!strcmp(#options, "windows-1251")) || (!strcmp(#options, "windows1251")) meta_encoding = _WIN; if (!strcmp(#options, "windows-1251")) || (!strcmp(#options, "windows1251")) meta_encoding = _WIN;
//if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) meta_encoding = _DOS; //if (!strcmp(#options, "dos")) || (!strcmp(#options, "cp-866")) meta_encoding = _DOS;
if ((cur_encoding==_DEFAULT) && (http_transfer==0)) BufEncode(meta_encoding); if (cur_encoding==_DEFAULT) BufEncode(meta_encoding);
return; return;
} }
} while(GetNextParam()); } while(GetNextParam());

View File

@ -30,14 +30,14 @@
#include "img\URLgoto.txt"; #include "img\URLgoto.txt";
#ifdef LANG_RUS #ifdef LANG_RUS
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.71"; char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 0.99.72";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­" ?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤" ?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤"
char loading[] = "‡ £à㧪  áâà ­¨æë...<br>"; char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
unsigned char page_not_found[] = FROM "html\page_not_found_ru.htm"; unsigned char page_not_found[] = FROM "html\page_not_found_ru.htm";
char accept_language[]= "Accept-Language: ru\n\0"; char accept_language[]= "Accept-Language: ru\n\0";
#else #else
char version[]=" Text-based Browser 0.99.71"; char version[]=" Text-based Browser 0.99.72";
?define IMAGES_CACHE_CLEARED "Images cache cleared" ?define IMAGES_CACHE_CLEARED "Images cache cleared"
?define T_LAST_SLIDE "This slide is the last" ?define T_LAST_SLIDE "This slide is the last"
char loading[] = "Loading...<br>"; char loading[] = "Loading...<br>";
@ -459,18 +459,15 @@ void ProcessLinks(int id)
void StopLoading() void StopLoading()
{ {
if (http_transfer<>0) EAX = http_transfer;
{ EAX = EAX.http_msg.content_ptr; // get pointer to data
EAX = http_transfer; $push EAX // save it on the stack
EAX = EAX.http_msg.content_ptr; // get pointer to data http_free stdcall (http_transfer); // abort connection
$push EAX // save it on the stack $pop EAX
http_free stdcall (http_transfer); // abort connection mem_Free(EAX); // free data
$pop EAX http_transfer=0;
mem_Free(EAX); // free data bufsize = 0;
http_transfer=0; PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
bufsize = 0;
PutPaletteImage(#toolbar,200,42,0,0,8,#toolbar_pal);
}
} }
void SetPageDefaults() void SetPageDefaults()
@ -495,6 +492,13 @@ void OpenPage()
_PutImage(88,10, 24,24, #stop_btn); _PutImage(88,10, 24,24, #stop_btn);
http_get stdcall (#URL, #accept_language); http_get stdcall (#URL, #accept_language);
http_transfer = EAX; http_transfer = EAX;
if (http_transfer == 0)
{
StopLoading();
bufsize = 0;
ShowPage();
return;
}
IF (http_transfer < 0) notify("Error from HTTP lib"); IF (http_transfer < 0) notify("Error from HTTP lib");
} }
else else

View File

@ -139,6 +139,12 @@ GETKEYII:
$shr eax,8 $shr eax,8
} }
inline fastcall int GetFullKey()
{
$mov eax,2
$int 0x40
}
inline fastcall pause( EBX) inline fastcall pause( EBX)
{ {
@ -362,6 +368,26 @@ DONE:
$pop eax $pop eax
} }
inline fastcall void debug( EDX)
{
$push eax
$push ebx
$push ecx
$mov eax, 63
$mov ebx, 1
NEXT_CHAR:
$mov ecx, DSDWORD[edx]
$or cl, cl
$jz DONE
$int 0x40
$inc edx
$jmp NEXT_CHAR
DONE:
$pop ecx
$pop ebx
$pop eax
}
inline fastcall void debugch( ECX) inline fastcall void debugch( ECX)
{ {