diff options
-rw-r--r-- | CHANGES | 8 | ||||
-rw-r--r-- | PACKAGE/lynx.spec | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAnchor.c | 6 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTAnchor.h | 6 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFormat.c | 39 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTMIME.c | 26 | ||||
-rw-r--r-- | src/GridText.c | 4 | ||||
-rw-r--r-- | src/LYShowInfo.c | 14 |
8 files changed, 66 insertions, 41 deletions
diff --git a/CHANGES b/CHANGES index 3dcd969b..4638a6bd 100644 --- a/CHANGES +++ b/CHANGES @@ -1,9 +1,13 @@ --- $LynxId: CHANGES,v 1.943 2018/03/09 01:45:26 tom Exp $ +-- $LynxId: CHANGES,v 1.944 2018/03/11 21:51:34 tom Exp $ =============================================================================== Changes since Lynx 2.8 release =============================================================================== -2018-03-05 (2.8.9dev.17) +2018-03-11 (2.8.9dev.17) +* improve logic in HTCopy used to limit reads based on content-length to + take into account server headers which extend past the first block read + (report/test-case by Dick Wesseling) -TD +* permanently enable EXP_HTTP_HEADERS feature -TD * modify color-style hashing to check for collisions -TD * add PREFERRED_CONTENT_TYPE defaulting to text/plain and options-menu to replace an assumption in HTMIMEConvert that everything is text/html. diff --git a/PACKAGE/lynx.spec b/PACKAGE/lynx.spec index 02c5af1c..67da4d54 100644 --- a/PACKAGE/lynx.spec +++ b/PACKAGE/lynx.spec @@ -1,4 +1,4 @@ -# $LynxId: lynx.spec,v 1.44 2017/08/08 22:32:03 tom Exp $ +# $LynxId: lynx.spec,v 1.45 2018/03/11 18:34:02 tom Exp $ Summary: A text-based Web browser Name: lynx Version: 2.8.9 @@ -29,7 +29,7 @@ HTTP, FTP, WAIS, and NNTP servers. %setup -q -n lynx%{version}%{release} %build -CPPFLAGS="-DMISC_EXP -DEXP_HTTP_HEADERS" \ +CPPFLAGS="-DMISC_EXP" \ %configure \ --target %{_target_platform} \ --prefix=%{_prefix} \ diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c index d782020b..ee983a77 100644 --- a/WWW/Library/Implementation/HTAnchor.c +++ b/WWW/Library/Implementation/HTAnchor.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAnchor.c,v 1.80 2018/03/06 09:34:12 tom Exp $ + * $LynxId: HTAnchor.c,v 1.81 2018/03/11 18:34:50 tom Exp $ * * Hypertext "Anchor" Object HTAnchor.c * ========================== @@ -762,9 +762,7 @@ static void HTParentAnchor_free(HTParentAnchor *me) } FREE(me->SugFname); FREE(me->cache_control); -#ifdef EXP_HTTP_HEADERS HTChunkClear(&(me->http_headers)); -#endif FREE(me->content_type_params); FREE(me->content_type); FREE(me->content_language); @@ -1067,14 +1065,12 @@ const char *HTAnchor_SugFname(HTParentAnchor *me) return (me ? me->SugFname : NULL); } -#ifdef EXP_HTTP_HEADERS /* HTTP Headers. */ const char *HTAnchor_http_headers(HTParentAnchor *me) { return (me ? me->http_headers.data : NULL); } -#endif /* Content-Type handling (parameter list). */ diff --git a/WWW/Library/Implementation/HTAnchor.h b/WWW/Library/Implementation/HTAnchor.h index e06ed017..3b1e6e68 100644 --- a/WWW/Library/Implementation/HTAnchor.h +++ b/WWW/Library/Implementation/HTAnchor.h @@ -1,5 +1,5 @@ /* - * $LynxId: HTAnchor.h,v 1.38 2017/02/10 22:26:48 tom Exp $ + * $LynxId: HTAnchor.h,v 1.40 2018/03/11 18:43:50 tom Exp $ * * Hypertext "Anchor" Object HTAnchor.h * ========================== @@ -100,10 +100,9 @@ extern "C" { char *SugFname; /* Suggested filename */ char *cache_control; /* Cache-Control */ BOOL no_cache; /* Cache-Control, Pragma or META "no-cache"? */ + BOOL inHEAD; /* HTMIMEConvert is decoding server-headers */ BOOL inBASE; /* duplicated from HTStructured (HTML.c/h) */ -#ifdef EXP_HTTP_HEADERS HTChunk http_headers; -#endif BOOL no_content_encoding; /* server did not use C-T? */ char *content_type_params; /* Content-Type (with parameters if any) */ char *content_type; /* Content-Type */ @@ -115,6 +114,7 @@ extern "C" { char *content_md5; /* Content-MD5 */ char *message_id; /* Message-ID */ char *subject; /* Subject */ + off_t header_length; /* length of headers */ off_t content_length; /* Content-Length */ off_t actual_length; /* actual length may differ */ char *date; /* Date */ diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c index ccab7d89..e1a173d5 100644 --- a/WWW/Library/Implementation/HTFormat.c +++ b/WWW/Library/Implementation/HTFormat.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFormat.c,v 1.86 2017/07/02 17:09:45 tom Exp $ + * $LynxId: HTFormat.c,v 1.89 2018/03/11 21:33:34 tom Exp $ * * Manage different file formats HTFormat.c * ============================= @@ -733,6 +733,7 @@ int HTCopy(HTParentAnchor *anchor, BOOL suppress_readprogress = NO; off_t limit = anchor ? anchor->content_length : 0; off_t bytes = 0; + off_t header_length = 0; int rv = 0; /* Push the data down the stream @@ -864,11 +865,39 @@ int HTCopy(HTParentAnchor *anchor, } #endif /* NOT_ASCII */ + header_length = anchor->header_length; + (*targetClass.put_block) (sink, input_buffer, status); - bytes += status; - if (!suppress_readprogress) - HTReadProgress(bytes, limit); - HTDisplayPartial(); + if (anchor->inHEAD) { + if (!suppress_readprogress) { + statusline(gettext("Reading headers...")); + } + CTRACE((tfp, "HTCopy read %" PRI_off_t " header bytes\n", + CAST_off_t (anchor->header_length))); + } else { + /* + * If header-length is increased at this point, that is due to + * HTMIME, which detects the end of the server headers. There + * may be additional (non-header) data in that block. + */ + if (anchor->header_length > header_length) { + int header = (int) (anchor->header_length - header_length); + + CTRACE((tfp, "HTCopy read %" PRI_off_t " header bytes " + "(%d extra vs %d total)\n", + CAST_off_t (anchor->header_length), + header, status)); + if (status > header) { + bytes += (status - header); + } + } else { + bytes += status; + } + if (!suppress_readprogress) { + HTReadProgress(bytes, limit); + } + HTDisplayPartial(); + } /* a few buggy implementations do not close the connection properly * and will hang if we try to read past the declared content-length. diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c index bc2fd1ec..d8fe9978 100644 --- a/WWW/Library/Implementation/HTMIME.c +++ b/WWW/Library/Implementation/HTMIME.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTMIME.c,v 1.97 2018/03/05 10:21:10 tom Exp $ + * $LynxId: HTMIME.c,v 1.100 2018/03/11 21:32:38 tom Exp $ * * MIME Message Parse HTMIME.c * ================== @@ -1079,7 +1079,9 @@ static int dispatchField(HTStream *me) */ static void HTMIME_put_character(HTStream *me, int c) { - /* MUST BE FAST */ + if (me->anchor->inHEAD) { + me->anchor->header_length++; + } switch (me->state) { begin_transparent: case MIME_TRANSPARENT: @@ -1309,6 +1311,9 @@ static void HTMIME_put_character(HTStream *me, int c) case '\n': /* Blank line: End of Header! */ { + me->anchor->inHEAD = FALSE; + CTRACE((tfp, "HTMIME length %" PRI_off_t "\n", + CAST_off_t (me->anchor->header_length))); me->net_ascii = NO; pumpData(me); } @@ -2046,7 +2051,6 @@ static void HTMIME_put_character(HTStream *me, int c) } /* switch on state */ -#ifdef EXP_HTTP_HEADERS HTChunkPutc(&me->anchor->http_headers, UCH(c)); if (me->state == MIME_TRANSPARENT) { HTChunkTerminate(&me->anchor->http_headers); @@ -2057,7 +2061,6 @@ static void HTMIME_put_character(HTStream *me, int c) CTRACE((tfp, "Server Content-Type:%s\n", me->anchor->content_type_params)); } -#endif return; value_too_long: @@ -2066,12 +2069,9 @@ static void HTMIME_put_character(HTStream *me, int c) bad_field_name: /* Ignore it */ me->state = miJUNK_LINE; -#ifdef EXP_HTTP_HEADERS HTChunkPutc(&me->anchor->http_headers, UCH(c)); -#endif return; - } /* String handling @@ -2177,13 +2177,14 @@ HTStream *HTMIMEConvert(HTPresentation *pres, me->anchor = anchor; me->anchor->safe = FALSE; me->anchor->no_cache = FALSE; + FREE(me->anchor->cache_control); FREE(me->anchor->SugFname); FREE(me->anchor->charset); -#ifdef EXP_HTTP_HEADERS + HTChunkClear(&me->anchor->http_headers); HTChunkInit(&me->anchor->http_headers, 128); -#endif + FREE(me->anchor->content_type_params); FREE(me->anchor->content_language); FREE(me->anchor->content_encoding); @@ -2191,15 +2192,21 @@ HTStream *HTMIMEConvert(HTPresentation *pres, FREE(me->anchor->content_disposition); FREE(me->anchor->content_location); FREE(me->anchor->content_md5); + + me->anchor->inHEAD = TRUE; + me->anchor->header_length = 0; me->anchor->content_length = 0; + FREE(me->anchor->date); FREE(me->anchor->expires); FREE(me->anchor->last_modified); FREE(me->anchor->ETag); FREE(me->anchor->server); + me->target = NULL; me->state = miBEGINNING_OF_LINE; me->format = HTAtom_for(ContentTypes[LYContentType]); + CTRACE((tfp, "default Content-Type is %s\n", HTAtom_name(me->format))); me->targetRep = pres->rep_out; me->boundary = NULL; /* Not set yet */ @@ -2209,6 +2216,7 @@ HTStream *HTMIMEConvert(HTPresentation *pres, me->c_t_encoding = 0; /* Not set yet */ me->compression_encoding = NULL; /* Not set yet */ me->net_ascii = NO; /* Local character set */ + HTAnchor_setUCInfoStage(me->anchor, current_char_set, UCT_STAGE_STRUCTURED, UCT_SETBY_DEFAULT); diff --git a/src/GridText.c b/src/GridText.c index 416f440e..21c57c37 100644 --- a/src/GridText.c +++ b/src/GridText.c @@ -1,5 +1,5 @@ /* - * $LynxId: GridText.c,v 1.308 2018/03/05 22:35:07 tom Exp $ + * $LynxId: GridText.c,v 1.309 2018/03/11 18:32:25 tom Exp $ * * Character grid hypertext object * =============================== @@ -7074,7 +7074,6 @@ const char *HText_getServer(void) HTAnchor_server(HTMainText->node_anchor) : 0); } -#ifdef EXP_HTTP_HEADERS /* * Returns the full text of HTTP headers, if available, for the current * document. @@ -7084,7 +7083,6 @@ const char *HText_getHttpHeaders(void) return (HTMainText ? HTAnchor_http_headers(HTMainText->node_anchor) : 0); } -#endif /* * HText_pageDisplay displays a screen of text diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c index 4c97e986..e787f701 100644 --- a/src/LYShowInfo.c +++ b/src/LYShowInfo.c @@ -1,4 +1,4 @@ -/* $LynxId: LYShowInfo.c,v 1.77 2018/03/02 01:53:43 tom Exp $ */ +/* $LynxId: LYShowInfo.c,v 1.79 2018/03/11 21:37:12 tom Exp $ */ #include <HTUtils.h> #include <HTFile.h> #include <HTParse.h> @@ -23,8 +23,6 @@ #include <LYLocal.h> #endif /* DIRED_SUPPORT */ -#define ADVANCED_INFO 1 /* to get more info in advanced mode */ - #define BEGIN_DL(text) fprintf(fp0, "<h2>%s</h2>\n<dl compact>", LYEntifyTitle(&buffer, text)) #define END_DL() fprintf(fp0, "\n</dl>\n") @@ -147,9 +145,8 @@ int LYShowInfo(DocInfo *doc, char *temp = 0; char *buffer = 0; -#ifdef ADVANCED_INFO BOOLEAN LYInfoAdvanced = (BOOL) (user_mode == ADVANCED_MODE); -#endif + #ifdef DIRED_SUPPORT struct stat dir_info; const char *name; @@ -377,7 +374,6 @@ int LYShowInfo(DocInfo *doc, if ((cp = HText_getLastModified()) != NULL && *cp != '\0') ADD_SS(gettext("Last Mod:"), cp); -#ifdef ADVANCED_INFO if (LYInfoAdvanced) { if (HTMainAnchor && HTMainAnchor->expires) { ADD_SS(gettext("Expires:"), HTMainAnchor->expires); @@ -398,7 +394,6 @@ int LYShowInfo(DocInfo *doc, ADD_SS(gettext("Language:"), HTMainAnchor->content_language); } } -#endif /* ADVANCED_INFO */ if (doc->post_data) { fprintf(fp0, "<dt><em>%s</em> <xmp>%.*s</xmp>\n", @@ -428,7 +423,6 @@ int LYShowInfo(DocInfo *doc, if (doc->internal_link) StrAllocCat(temp, gettext(", via internal link")); -#ifdef ADVANCED_INFO if (LYInfoAdvanced) { if (HText_hasNoCacheSet(HTMainText)) StrAllocCat(temp, gettext(", no-cache")); @@ -437,7 +431,6 @@ int LYShowInfo(DocInfo *doc, if (doc->bookmark) StrAllocCat(temp, gettext(", bookmark file")); } -#endif /* ADVANCED_INFO */ ADD_SS(gettext("mode:"), temp); FREE(temp); @@ -483,15 +476,12 @@ int LYShowInfo(DocInfo *doc, gettext("No Links on the current page"))); } -#ifdef EXP_HTTP_HEADERS if ((cp = HText_getHttpHeaders()) != 0) { fprintf(fp0, "<h2>%s</h2>", LYEntifyTitle(&buffer, gettext("Server Headers:"))); fprintf(fp0, "<pre>%s</pre>", LYEntifyTitle(&buffer, cp)); } -#endif - #ifdef DIRED_SUPPORT } #endif /* DIRED_SUPPORT */ |