diff --git a/Resources/UK/Browse/!Run,feb b/Resources/UK/Browse/!Run,feb index 1f58000cb542fec332fce52d8a99dfc52f9ec88b..8c7e7c6b0e816bb0c7fac5d783c0cc74ded40d6e 100644 --- a/Resources/UK/Browse/!Run,feb +++ b/Resources/UK/Browse/!Run,feb @@ -3,8 +3,7 @@ Set Browse$Path <Browse$Dir>. | HTTP fetcher controls -Set Browse$FakeNetscape off -Set Browes$AcceptAllCookies off +Set Browes$AcceptAllCookies on UnSet Browse$CookiePath | Ensure specific versions of Toolbox modules (or later ones) diff --git a/Resources/UK/Browse/!RunD,feb b/Resources/UK/Browse/!RunD,feb index 4d1105771edf780c9d56979c653faf7d151c1acf..7bb489a60d573dfb5c5521e7f91db0db8e31ad2b 100644 --- a/Resources/UK/Browse/!RunD,feb +++ b/Resources/UK/Browse/!RunD,feb @@ -3,8 +3,7 @@ Set Browse$Path <Browse$Dir>. | HTTP fetcher controls -Set Browse$FakeNetscape off -Set Browse$AcceptAllCookies off +Set Browes$AcceptAllCookies on UnSet Browse$CookiePath | Ensure specific versions of Toolbox modules (or later ones) diff --git a/Resources/UK/Browse/Messages b/Resources/UK/Browse/Messages index 4feddc25dae33db3a358de202f736289f98a08f1..df5aaaa204ea4745de843a0504d26282997163b2 100644 --- a/Resources/UK/Browse/Messages +++ b/Resources/UK/Browse/Messages @@ -32,6 +32,7 @@ WhatSave:Internal error - Save dialogue origin not understood in save_fill_in(). BadType:Internal error - Bad typeface definition in %0(). BadTRef:Internal error - Reference to undefined typeface in %0(). +NoContxt:Serious internal error - Block is already free or was not HtmlAlloc'd in html_close(); must exit immediately. HSHOvrrn:Serious internal error - HtmlStripHeaders has failed; must exit immediately. STCUnkwn:Serious internal error - Unknown chunk ID in memory_set_chunk_size(); must exit immediately. diff --git a/Resources/UK/Phoenix/Messages b/Resources/UK/Phoenix/Messages index 5c3dca4a76c7eacba40c9f941ae92383f7fc1190..5d9de83ad225662c526a07808ce58f8dff84deaa 100644 --- a/Resources/UK/Phoenix/Messages +++ b/Resources/UK/Phoenix/Messages @@ -32,6 +32,7 @@ WhatSave:Internal error - Save dialogue origin not understood in save_fill_in(). BadType:Internal error - Bad typeface definition in %0(). BadTRef:Internal error - Reference to undefined typeface in %0(). +NoContxt:Serious internal error - Block is already free or was not HtmlAlloc'd in html_close(); must exit immediately. HSHOvrrn:Serious internal error - HtmlStripHeaders has failed; must exit immediately. STCUnkwn:Serious internal error - Unknown chunk ID in memory_set_chunk_size(); must exit immediately. diff --git a/c/Browser b/c/Browser index 00000eae48b7998675c80afd6ffd5bfa6580987c..4e3b9d1c3b540f298c2d26dc4d20c8050707a46a 100644 --- a/c/Browser +++ b/c/Browser @@ -553,7 +553,10 @@ HStream * browser_find_selectable_top_r(browser_data * b, reformat_cell * cell, { int extent = cell->ldata[cell->nlines - 1].y; int average = extent / cell->nlines; - int startat = ytop / average; + int startat; + + if (average) startat = ytop / average; + else startat =0; if (startat < 0) startat = 0; if (startat >= cell->nlines) startat = cell->nlines - 1; diff --git a/c/Cookies b/c/Cookies index a713ebde1a799d16eca7c344bea532d26b8460b2..10e737f8418f19647e08c3286442439f417f3e4d 100644 --- a/c/Cookies +++ b/c/Cookies @@ -86,8 +86,6 @@ _kernel_oserror * cookies_process_cookie(browser_data * b) if (e) return e; if (!handle) break; - - Printf("cookie name: '%s'\n",name); } return NULL; diff --git a/c/Fetch b/c/Fetch index 26961f0daf0b2e9b2db7cdc6a311599d4675732b..e272940cd155788f6c0a6d03d6bd6067c3f33e4e 100644 --- a/c/Fetch +++ b/c/Fetch @@ -462,9 +462,68 @@ void fetch_preprocess_token(browser_data * b, HStream * tptr) } else b->formflag = 0; - /* Closure of long if to see if the HStream structure represented */ - /* a body tag or header information - the code is run if it's a */ - /* body tag. */ + /* Tables - need to preprocess any HStreams attached as part of a table */ + /* tag. Because any one token is only run through this preprocessor */ + /* once, and because when this table tag is run through it all of the */ + /* HStreams within may not have arrived yet (the page is only partially */ + /* fetched), it is still necessary to rescan the attached HStreams at a */ + /* later date (e.g. as part of the reformatting process) to ensure they */ + /* are all preprocessed correctly. */ + + if (tptr->tag == TABLE) + { + table_stream * table = (table_stream *) tptr; + table_row * R; + table_headdata * D; + HStream * attached, * temp; + + R = table->List; + + /* Scan the rows and cells */ + + while (R) + { + D = R->List; + + while (D) + { + if (D->Tag) + { + switch (D->Tag) + { + case TagTableData: + case TagTableHead: + { + attached = (HStream *) D->List; + + /* Preprocess any attached HStream list */ + + while (attached) + { + if (!(attached->flags & HFlags_DealtWithToken)) + { + temp = b->finaltoken; + fetch_preprocess_token(b, attached); + b->finaltoken = temp; + } + + attached = attached->next; + } + } + break; + } + } + + D = D->Next; + } + + R = R->Next; + } + } + + /* Closure of long 'if' to see if the HStream structure represented */ + /* a body tag or header information - the code is run if it's a */ + /* body tag. */ } #ifdef FRAMES_SUPPORT @@ -1707,7 +1766,11 @@ _kernel_oserror * html_get(char * url, char * extradata, int * handle, int metho fetch_list = up; - /* If there is any extra data for POST or whatever, deal with it */ + /* If there is any extra data for POST or whatever, deal with it. */ + /* The POST request entries must come first in the extra header */ + /* info, so that the browser can make the assumption that */ + /* everything from Content-Type forwards may be stripped in the */ + /* event of a redirection when the current fetch method is POST. */ if (extradata) { @@ -1745,7 +1808,9 @@ _kernel_oserror * html_get(char * url, char * extradata, int * handle, int metho strcpy(up->extradata + 2, extradata); - /* Header entry for the extra data */ + /* Header entry for the extra data - again, the removal routines in the */ + /* fetcher's redirection code assume that this comes before Content-Type */ + /* and the actual body content to make life easy there. */ sprintf(head, "Content-Length: %d", len); @@ -2008,7 +2073,51 @@ _kernel_oserror * html_close(unsigned int handle) } #endif - if (up->stream) HtmlStreamFree(up->stream); + if (up->stream) + { + unsigned int context = HtmlReturnContext(up->stream); + browser_data * browser = last_browser; + + /* Should Never Happen...! */ + + if (!context) + { + erb.errnum = Utils_Error_Custom_Fatal; + + StrNCpy0(erb.errmess, + lookup_token("NoContxt:Serious internal error - Block is already free or was not HtmlAlloc'd in html_close(); must exit immediately.", + 0, + 0)); + + return &erb; + } + + /* Ensure that any HStream pointers inside any current browser_data */ + /* structures are not part of this stream - if so, clear them. */ + + while (browser) + { + /* For now, just a few selected items */ + + if (browser->selected && HtmlReturnContext(browser->selected) == context) + { + browser_clear_selection(browser, 0); + browser->selected = NULL; + } + + if (browser->highlight && HtmlReturnContext(browser->highlight) == context) + { + browser_clear_highlight(browser, 0); + browser->highlight = NULL; + } + + if (browser->pointer_over && HtmlReturnContext(browser->pointer_over) == context) browser->pointer_over = NULL; + + browser = browser->previous; + } + + HtmlStreamFree(up->stream); + } if (up->context) { @@ -2638,11 +2747,68 @@ _kernel_oserror * html_get_next_token(browser_data * b, unsigned int handle, int flex_free(source); *source = NULL; + /* Ensure POST requests are now cleared (we shouldn't continue */ + /* POSTing to redirected URLs) */ + + if (up->method == URL_Method_http_POST) + { + /* When the headers are build, the POST data (starting with a Content-Length */ + /* entry) are put in first and everything else is inserted above it. As the */ + /* comments on this code say, this is organised so we can simplify things */ + /* here and just chop off everything at Content-Length and below, rather */ + /* than having to carefully remove the appropriate header lines and body. */ + + if (up->extradata) + { + char * strip = strstr(up->extradata, "Content-Length"); + + if (strip) + { + int len; + + /* How much do we want to keep? */ + + len = strstr(up->extradata, "Content-Length") - up->extradata; /* Don't use 'strip' in case flex shifted when 'len' was stacked */ + + #ifdef TRACE + { + int rmv = flex_size((flex_ptr) &up->extradata) - len; + flexcount -= rmv; + if (tl & (1u<<13)) Printf("** flexcount: %d\n",flexcount); + } + #endif + + /* Resize the block */ + + flex_extend((flex_ptr) &up->extradata, len); + } + } + + /* Change the fetch method to GET */ + + up->method = URL_Method_http_GET; + } + + #ifdef TRACE + if (up->extradata) + { + flexcount -= flex_size((flex_ptr) &up->extradata); + if (tl & (1u<<13)) Printf("** flexcount: %d\n",flexcount); + } + #endif + + if (up->extradata) flex_free((flex_ptr) &up->extradata); + + up->method = URL_Method_http_GET; + /* Customer specific */ #ifdef CUSTOMER_SPECIAL - if (!strcmp(redirect,"http://www.customer.net/login.cgi")) + if ( + !strcmp(redirect,"http://www.customer.net/login.cgi") || + !strcmp(redirect,"http://www.customer.com/index.html") + ) { // Send out cookie... diff --git a/c/Handlers b/c/Handlers index 4ea3e2364cee8581a948e396fa7d51598c29841e..c3c759df2c721db172dcaa3269f79ce51e023f49 100644 --- a/c/Handlers +++ b/c/Handlers @@ -1628,131 +1628,147 @@ int handle_link_clicks(int eventcode, WimpPollBlock * b, IdBlock * idb, browser_ { if (p->anchor) { + int ignore = 0; + /* First, do we have JavaScript code to deal with? */ - if (p->onclick && *p->onclick) ChkError(javascript_href_onclick(handle, p)); + if (p->onclick && *p->onclick) ChkError(javascript_href_onclick(handle, p, &ignore)); - /* Image maps */ + /* If ignore is zero, we're supposed to deal with the HREF attribute */ + /* on the link - otherwise, ignore it. */ - if ((p->style & IMG) && (p->type & TYPE_ISMAP)) + if (!ignore) { - WimpGetWindowStateBlock s; - char coords[64]; - browser_data * targetted; - BBox box; - int x, y; + /* Image maps */ - if (eventcode < 0) + if ((p->style & IMG) && (p->type & TYPE_ISMAP)) { - ChkError(wimp_get_pointer_info(&i)); - p = browser_get_pointer_token(handle, &i, NULL, NULL); - if (!p) return 0; - } + WimpGetWindowStateBlock s; + char coords[64]; + browser_data * targetted; + BBox box; + int x, y; - /* Get the image's size and position on screen */ + if (eventcode < 0) + { + ChkError(wimp_get_pointer_info(&i)); + p = browser_get_pointer_token(handle, &i, NULL, NULL); + if (!p) return 0; + } - s.window_handle = handle->window_handle; - if (wimp_get_window_state(&s)) return 0; + /* Get the image's size and position on screen */ - if (image_get_token_image_size(handle, p, &box)) return 0; - if (image_get_token_image_position(handle, p, &x, &y)) return 0; + s.window_handle = handle->window_handle; + if (wimp_get_window_state(&s)) return 0; - x = coords_x_toscreen(x, (WimpRedrawWindowBlock *) &s); - y = coords_y_toscreen(y, (WimpRedrawWindowBlock *) &s); + if (image_get_token_image_size(handle, p, &box)) return 0; + if (image_get_token_image_position(handle, p, &x, &y)) return 0; - /* Get the offset of the pointer position from the top left */ - /* of the image in ox and oy */ + x = coords_x_toscreen(x, (WimpRedrawWindowBlock *) &s); + y = coords_y_toscreen(y, (WimpRedrawWindowBlock *) &s); - ox = i.x - x; - oy = y + (box.ymax - box.ymin) - i.y; + /* Get the offset of the pointer position from the top left */ + /* of the image in ox and oy */ - if (ox >= 0 && oy >= 0) - { - /* Convert the coordinate to pixels and build an appropriate */ - /* CGI string including this information. */ + ox = i.x - x; + oy = y + (box.ymax - box.ymin) - i.y; - image_convert_to_pixels(handle, p, &ox, &oy); - sprintf(coords, "?%d,%d", ox, oy); + if (ox >= 0 && oy >= 0) + { + /* Convert the coordinate to pixels and build an appropriate */ + /* CGI string including this information. */ - history_record_global(p->anchor); - targetted = frames_find_target(handle, p); + image_convert_to_pixels(handle, p, &ox, &oy); + sprintf(coords, "?%d,%d", ox, oy); - if (targetted || choices.full_screen) - { - /* If a named target was found, open in that. Otherwise we must */ - /* be running full screen, so can't open a new window; in this */ - /* case, open in the ancestor. */ + history_record_global(p->anchor); + targetted = frames_find_target(handle, p); - ChkError(fetchpage_new_add(targetted ? targetted : ancestor, - p->anchor, - 1, - coords, - adj)); - } - else - { - /* If we've reached here, a named target wasn't found but the */ - /* browser isn't running full screen either, so open a new */ - /* window with the name specified in the link. */ - - ChkError(windows_create_browser(p->anchor, - NULL, - NULL, - p->target)); + if (targetted || choices.full_screen) + { + /* If a named target was found, open in that. Otherwise we must */ + /* be running full screen, so can't open a new window; in this */ + /* case, open in the ancestor. */ + + ChkError(fetchpage_new_add(targetted ? targetted : ancestor, + p->anchor, + 1, + coords, + adj)); + } + else + { + /* If we've reached here, a named target wasn't found but the */ + /* browser isn't running full screen either, so open a new */ + /* window with the name specified in the link. */ + + ChkError(windows_create_browser(p->anchor, + NULL, + NULL, + p->target)); + } } - } - used = 1; - } + used = 1; + } - /* Otherwise, a simple link */ + /* Otherwise, a simple link */ - else - { - if (!adj) + else { - browser_data * targetted; + if (!adj) + { + browser_data * targetted; - history_record_global(p->anchor); - targetted = frames_find_target(handle, p); + history_record_global(p->anchor); + targetted = frames_find_target(handle, p); - /* Don't want to ever open a new window if configured */ - /* to run full screen. */ + /* Don't want to ever open a new window if configured */ + /* to run full screen. */ - if (targetted || choices.full_screen) - { - /* If a named target was found, open in that. Otherwise we must */ - /* be running full screen, so can't open a new window; in this */ - /* case, open in the ancestor. */ + if (targetted || choices.full_screen) + { + /* If a named target was found, open in that. Otherwise we must */ + /* be running full screen, so can't open a new window; in this */ + /* case, open in the ancestor. */ - ChkError(fetchpage_new(targetted ? targetted : ancestor, - p->anchor, - 1)); - } - else - { - /* If we've reached here, a named target wasn't found but the */ - /* browser isn't running full screen either, so open a new */ - /* window with the name specified in the link. */ - - ChkError(windows_create_browser(p->anchor, - NULL, - NULL, - p->target)); + ChkError(fetchpage_new(targetted ? targetted : ancestor, + p->anchor, + 1)); + } + else + { + /* If we've reached here, a named target wasn't found but the */ + /* browser isn't running full screen either, so open a new */ + /* window with the name specified in the link. */ + + ChkError(windows_create_browser(p->anchor, + NULL, + NULL, + p->target)); + } } - } - /* Yes, this 'else' would mean that even if running */ - /* full screen, an Adjust click would open a new */ - /* window - but note the fixed.ignoreadjust choices */ - /* option, which disables the use of adjust and can */ - /* be used in conjunction with the full screen */ - /* option. */ - - else ChkError(windows_create_browser(p->anchor, - NULL, - NULL, - NULL)); + /* Yes, this 'else' would mean that even if running */ + /* full screen, an Adjust click would open a new */ + /* window - but note the fixed.ignoreadjust choices */ + /* option, which disables the use of adjust and can */ + /* be used in conjunction with the full screen */ + /* option. */ + + else ChkError(windows_create_browser(p->anchor, + NULL, + NULL, + NULL)); + + used = 1; + } + } + else + { + /* The JavaScript routines said that the HREF contents of the link */ + /* should be ignored; so just flag that we've dealt with this, but */ + /* do nothing else. */ used = 1; } diff --git a/c/JavaScript b/c/JavaScript index e0dced651d0368f33210f750caa300f28b8bee92..1bf22b7c3be2c54b9574890df90a2f9e2a3218f1 100644 --- a/c/JavaScript +++ b/c/JavaScript @@ -92,10 +92,18 @@ _kernel_oserror * javascript_body_onload(browser_data * b) /* relevant to the item clicked on; */ /* */ /* Pointer to the token representing */ -/* that item. */ +/* that item; */ +/* */ +/* Pointer to an int, in which 1 is */ +/* written if the contents of the */ +/* HREF attribute in the link that */ +/* held the onClick should be */ +/* ignored (else 0 is written) - */ +/* this may be NULL if you're not */ +/* interested. */ /*************************************************/ -_kernel_oserror * javascript_href_onclick(browser_data * b, HStream * t) +_kernel_oserror * javascript_href_onclick(browser_data * b, HStream * t, int * ignore) { _kernel_oserror * e = NULL; @@ -103,13 +111,15 @@ _kernel_oserror * javascript_href_onclick(browser_data * b, HStream * t) if (tl & (1u<<24)) Printf("javascript_href_onclick: Called\n"); #endif + if (ignore) *ignore = 0; + #ifdef CUSTOMER_SPECIAL /* Only call customer_ functions if on the customer's site */ if (strstr(browser_current_url(b), "www.customer.com")) { - e = customer_href_onclick(b, t); + e = customer_href_onclick(b, t, ignore); } #endif diff --git a/c/Main b/c/Main index 17bacc4344ad861025d7d04bb2174e5733944ea2..8dd809730b9684b7bda2d02b919ef796b03b2726 100644 --- a/c/Main +++ b/c/Main @@ -482,7 +482,7 @@ static void initialise_app(void) /* Try and set the user agent string for HTTP fetches. */ - show_error(utils_set_http_agent()); +// show_error(utils_set_http_agent()); /* Find out window tool sizes */ diff --git a/c/Reformat b/c/Reformat index e21fa7a9a3f640fe89aa97dfb6701ede5e57eb9b..54cb4723b6e1b1dbf82e7852a7afdd2797576d12 100644 --- a/c/Reformat +++ b/c/Reformat @@ -354,7 +354,7 @@ static _kernel_oserror * reformat_token_width(reformat_width_data * w, unsigned convert_box_to_points(&box, &box); - w->width = (box.xmax - box.xmin) * length + 16*400 + extra; + w->width = (((box.xmax - box.xmin) * length * 2) / 3) + 16 * 400 + extra; fm_lose_font(NULL, h); w->bytes = 0; @@ -1299,9 +1299,15 @@ int reformat_bullet_height(int bullet) int reformat_y_offset (browser_data * b) { + int offset = toolbars_button_height(b) + toolbars_url_height(b); + /* The '4' accounts for the bottom window frame of the toolbars */ - return -(toolbars_button_height(b) + toolbars_url_height(b) + b->leading + 4); + if (offset) offset += wimpt_dy(); + + if (!b->ancestor) offset += b->leading; /* Only put a gap at the top for base browsers, not for frames */ + + return -offset; } /*************************************************/ diff --git a/c/TokenUtils b/c/TokenUtils index 77102a863da52eed398653e0e291de1b6e05649b..dae7eb5cb24bf006ce67b2df969e37df69b72186 100644 --- a/c/TokenUtils +++ b/c/TokenUtils @@ -95,11 +95,13 @@ void tokenutils_anchor_range(browser_data * b, HStream * token, HStream ** first if (first) *first = NULL; if (last) *last = NULL; + if (!b || !token) return; + /* Can only proceed if the given token represents a link */ if (token && (token->style & A) && token->anchor) { - top = token; + store = top = token; /* Move up the token list for as long as the token given matches */ /* the details of the token being looked at. */ @@ -123,9 +125,9 @@ void tokenutils_anchor_range(browser_data * b, HStream * token, HStream ** first !strcmp(top->anchor, token->anchor) ) ) - top = top->next ? top->next : NULL; + top = top->next; - end = token; + store = end = token; /* Similary, move down the token list to find the first token after */ /* all those involved in the link. */ @@ -151,7 +153,7 @@ void tokenutils_anchor_range(browser_data * b, HStream * token, HStream ** first !strcmp(end->anchor, token->anchor) ) ) - end = end->prev ? end->prev : NULL; + end = end->prev; } else top = end = token; diff --git a/c/Trace b/c/Trace index 824608c3e896435f74c42510fdce26ffde44082b..43fabc3806ed764596953fa852c63db73aad4abd 100644 --- a/c/Trace +++ b/c/Trace @@ -71,7 +71,7 @@ static int trace_dump_head (FILE * file, table_headdata * head, int depth); /*************************************************/ - /* trace_dump_tokens_by_line */ + /* trace_dump_tokens_by_line() */ /* */ /* Outputs a diagnostic description of the */ /* token list of a browser. The browser is */ @@ -401,7 +401,7 @@ tdtbl_fo_err: /* If there's an error whilst writing to the file */ } /*************************************************/ - /* trace_dump_tokens_by_stream */ + /* trace_dump_tokens_by_stream() */ /* */ /* Outputs a diagnostic description of the */ /* token list of a browser. The browser is */