aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES.new141
-rw-r--r--LYMessages_en.h10
-rw-r--r--Makefile.old1
-rw-r--r--WWW/Library/Implementation/HTAlert.h4
-rw-r--r--WWW/Library/Implementation/HTAnchor.c22
-rw-r--r--WWW/Library/Implementation/HTAnchor.h16
-rw-r--r--WWW/Library/Implementation/HTFile.c237
-rw-r--r--WWW/Library/Implementation/HTFormat.c165
-rw-r--r--WWW/Library/Implementation/HTFormat.h20
-rw-r--r--WWW/Library/Implementation/HTMIME.c23
-rw-r--r--WWW/Library/Implementation/HTML.h4
-rw-r--r--WWW/Library/Implementation/HTNews.c373
-rw-r--r--WWW/Library/Implementation/HTStyle.h2
-rw-r--r--WWW/Library/Implementation/HTTCP.c107
-rw-r--r--WWW/Library/Implementation/HTTP.c139
-rw-r--r--WWW/Library/Implementation/HTUtils.h2
-rw-r--r--WWW/Library/djgpp/makefile2
-rw-r--r--lynx.cfg1
-rw-r--r--makefile.in1
-rw-r--r--samples/lynx.cfg2
-rw-r--r--samples/mailcap2
-rw-r--r--src/DefaultStyle.c100
-rw-r--r--src/GridText.c299
-rw-r--r--src/GridText.h4
-rw-r--r--src/HTAlert.c90
-rw-r--r--src/HTAlert.h4
-rw-r--r--src/HTFWriter.c147
-rw-r--r--src/HTFont.h2
-rw-r--r--src/HTInit.c9
-rw-r--r--src/HTML.c75
-rw-r--r--src/HTML.h4
-rw-r--r--src/LYCharUtils.c103
-rw-r--r--src/LYCookie.c430
-rw-r--r--src/LYCurses.c6
-rw-r--r--src/LYForms.c3
-rw-r--r--src/LYGetFile.c52
-rw-r--r--src/LYLocal.c4
-rw-r--r--src/LYMain.c4
-rw-r--r--src/LYMainLoop.c63
-rw-r--r--src/LYOptions.c3
-rw-r--r--src/LYShowInfo.c3
-rw-r--r--src/LYUtils.c122
-rw-r--r--src/Makefile1
-rw-r--r--src/UCAux.c5
-rw-r--r--src/UCdomap.c3
-rw-r--r--src/chrtrans/MAKEW32.BAT4
-rw-r--r--src/chrtrans/Makefile1
-rw-r--r--src/chrtrans/build-chrtrans.com2
-rw-r--r--src/chrtrans/cp1251_uni.tbl1
-rw-r--r--src/chrtrans/cp866_uni.tbl189
-rw-r--r--src/chrtrans/koi8r_uni.tbl14
-rw-r--r--src/chrtrans/makefile.in1
-rw-r--r--src/makefile.in1
53 files changed, 2330 insertions, 693 deletions
diff --git a/CHANGES.new b/CHANGES.new
index 8767dc0d..6af37118 100644
--- a/CHANGES.new
+++ b/CHANGES.new
@@ -10,11 +10,104 @@ README.configure), and miscellaneous other changes. Note that the 2.7 ->
2.7.1 changes (which are listed at the beginning of the current CHANGES
file) are duplicated here. - KW]
+1997-08-16
+* Mini tweaks for the win-dos ports. One fix for the pull down boxes
+ and the rest mostly maintence. - WB
+1997-08-15
+* Hack in highlight() to preserve a '-' character at the end of line
+ within anchor text, which can result from splitting at the position
+ of a &shy; or <SHY> or SOFT HYPHEN character. - KW
+* Tweaks in print_wwwfile_to_fd print_crawl_to_fd to output a soft hyphen
+ character if it is present at the end of a line. For -dump, a raw
+ ISO 8859 SOFT HYPHEN character may be written if the Display Character
+ Set (default from lynx.cfg or saved value in .lynxrc) is an ISO 8859
+ character set, but this may be overridden with the -raw toggle.
+ Otherwise represent soft hyphen with '-' as usual. - KW
+* Modified the news gateway to try XGTITLE for wildcarded lists of
+ available newsgroups (e.g., news:bionet.* for the bionet hierarchy,
+ or news:* for all of its served newsgroups). If that fails, Lynx
+ retries with the old behavior of using LIST NEWSGROUPS and parsing
+ the reply itself for the desired groups. Note that LIST NEWSGROUPS
+ can take a wildcarded argument for some nntp servers, but not all,
+ so we don't risk it. - FM
+* Fixed a bug in HTHandleAuthInfo() of yesterday's HTNews.c which could
+ yield an infinite while() loop. - FM
+* Various tweaks in HTNews.c to HTHandleAuthInfo() and elsewhere, to
+ keep connections open more often in some common cases of non-fatal
+ errors, and also avoid trying to use the network socket after some
+ recognized case of closing by the server. Only based on some testing
+ with INN's nnrpd, not on any written specs. - KW
+1997-08-14
+* Added nntp authorization (AUTHINFO) handling to the news gateway. - FM
+* Added a "Loading cfg file '%s'." trace message in LYMain.c to indicate
+ the absolute path of the configuration (lynx.cfg) file which was used
+ at startup (if Lynx is invoked with the -trace command line switch). - FM
+* Added code in HTFWriter.c to avoid calling HTLoadFile() on the temporary
+ file which results from decompression of a temporary file created by
+ HTCompressed(), if this would just result in making a copy of the file
+ and then invoking an external viewer. Instead the viewer command is
+ now invoked directly from the HTFWriter_free of the HTCompressed()
+ stream after decompression. - KW
+* Added code in HTFWriter.c, HTFile.c, and HTFormat.c to support reading
+ of gzipped local files directly, using functions from the zlib library.
+ Note that gzipped files from remote servers are still first copied to
+ a temporary file before lynx can process them further, and an external
+ GZIP_PATH command is still needed at least for passing such files to an
+ external viewer, as well as for various DIRED_SUPPORT File menu functions.
+ To activate this code, the symbol USE_ZLIB has to be defined, it is
+ currently not set by the auto-config script. The zlib library may be
+ already installed on your system (probably called libz.a or libz.so.1
+ or similar, the required header files are zlib.h and zconf.h), otherwise
+ it is available through <http://www.cdrom.com/pub/infozip/zlib/>, it
+ appears to support all platforms for which lynx is available (including
+ VMS, DOS, MS Win32). Note that this library would probably also be
+ needed if in the future support for the HTTP/1.1 "deflate" content-coding
+ is added. - KW
+* Don't send MIME types in Accept headers whose q values are outside of the
+ allowed range 0.0 <= q <= 1.0 - KW
+* Tweaks in HTInit.c to use the official names for image/png and image/tiff,
+ but still support the image/x-* forms. - KW
+1997-08-13
+* Tweaks of LYConvertToURL() in LYUtils.c and HTParseInet() in HTTCP.c
+ to deal more coherantly with 'z'ap attempts during gethostbyname()
+ calls. - FM
+* Tweaks of split_line() and HText_endAppend() in GridText.c to handle
+ trimming of spaces from the tails of link names more effectively. - FM
+* Expanded the OL nesting depth and type counters to track up to 12 list
+ depths before punting to the lowest negative number. Note that the
+ indentations still are limited to 6 nested depths, so use the TYPE
+ attribute to distinquish OLs with deeper nestings. - FM
+1997-08-12
+* Mods of LYMainLoop.c to maintain treatment of a local startfile as
+ text/html source when it does not have a suffix mapped to that MIME
+ type and the -force_html switch was used. - FM
+* Added .phtml to the default suffix mappings for text/html. - FM
+* Mods of LYCurses.c to avoid using /dev/tty arbitrarily for stdin on
+ Unix when compiling with slang versions greater than 0.99-35, based
+ on JED's suggestion to lynx-dev. - FM
+* Tweaks of HTCheckFnameForCompression() in GridText.c to avoid warnings
+ from some compilers. - FM
+1997-08-09
+* Changed the code of 1997-08-06 which modifies suggested filenames for a
+ 'D'ownload to be more cautious: don't remove a '.gz', '.Z' etc. suffix
+ if there is no header indication that we have a compressed file. Not
+ all servers and gateways (including the internal FTP gateawy) detect
+ and label compressed content reliably. - KW
+1997-08-08
+* Mods of HTTP.c so that download requests are converted to presentation
+ requests for interactive users, and traversal requests are converted to
+ cancels, when servers return non-success statuses with bodies which
+ should be displayed to interactive users. - FM
+* Added the "DosCyrillic (cp866)" display character set to the chartrans
+ support, and tweaked the other Cyrillic charset tables. - AAC & KW
+* Tweaked MULTI_SUFFIX support in HTFile.c, so that it now somewhat
+ works. Dunno whether it's useful for anybody. - KW
1997-08-07
+* Tweaks of yesterdays mods in GridText.c. - FM
* Correct storage class of variables in UCMap.h, from -warn-common linker
- option.
+ option. - TD
* Refine configure tests for acs_map, ttytype to accommodate broken linker
- on FreeBSD 2.1.5
+ on FreeBSD 2.1.5 - TD
* Modify README.configure to indicate the associated definitions for
each configure option, as suggested by Klaus Weide. - TD
* Correct duplicate declaration of Current_Attr, which Linux linker ignores
@@ -35,6 +128,24 @@ file) are duplicated here. - KW]
a loop forcing the entries of acs_map[] to 8-bits. - TD
* Many minor tweaks for the DJGPP version by DK - WB
* A rename of about_lynx_dev.html to lynx_dev.html for 8.3 systems - WB
+1997-08-06
+* Modified HTMIME.c and LYCharUtils.c so that setting of suggested filenames
+ via a filename=value pair in Content-Disposition headers and META elements
+ is not restricted to the file disposition type. - FM
+* Mods in GridText.c, LYGetFile.c and HTAnchor.c so that suggested filenames
+ will have appropriate suffixes when 'd'ownloading, based on whether or not
+ the file is gzipped or Unix compressed. - FM
+1997-08-05
+* Mods of the lead relative symbolic element stripping for http/https
+ URLs in cases for which they would persist when resolved to an
+ absolute URL. The lastest URL draft is ambiguous about whether this
+ should be considered an error, and leaves the handling of it up to the
+ UA. So we now get rid of all lead relative symbolic elements from the
+ resolved http/https URLs, but no others, and still issue a Bad Partial
+ Reference statusline message. - FM
+* Tweaks of title handling in LYMainLoop.c and LYShowInfo.c so that the
+ known title, or link name associated with ACTIVATE-ion, form submission,
+ or a HEAD request, will be used in the INFO ('=') display. - FM & KW
1997-08-04
* Fixed header parsing in HTMIME.c so that "Safe:" is recognized. - KW
* Changed confirmation prompts for HEAD (']') commands acting on a POST
@@ -49,9 +160,33 @@ file) are duplicated here. - KW]
is retried without forking if the child process exits without returning
enough data. Also added trace output, to show whether something
unusual has happened to the child process. - KW
+* The IETF has indicated intent to adopt KW's "status 307" proposal for
+ dealing with the status 302 problems, so HTTP.c and HTAlert.c implement
+ that now. The 302 status is "General (temporary) Redirection" which
+ can be handled as 303 at the UA's discretion, so we do that in all cases,
+ rather than prompting the user whether to do that when the 302 is for
+ a POST submission. The 307 (and 305) for POST submissions invokes a
+ prompt whether to P)roceed or C)ancel, without the Use G)ET option.
+ The 301 is treated as permanent, normally, but for POST submissions
+ still is treated as temporary and invokes a prompt which includes the
+ Use G)ET option, because scripts written to empirical behavior may
+ still be expecting that (it's virtually never encountered in redirections
+ of POSTs, though, because the document containing the form typically
+ is redirected, so the user only sees the form if a local copy has been
+ made, and it would be best to C)ancel and get a new local copy of the
+ document from the correct http/https URL, to serve as a BASE for the
+ form's ACTION). - FM
* Changed the typedef for HTCoord in HTStyle.h from float to int, for
significant speedup of rendering on machines without floating-point
- hardware. - KW
+ hardware based on DW's, KW's, BL's analyses. Note that this should
+ be taken into account when/if external style sheet support is added
+ for page formatting (e.g., for optimum handling by speech synthesizers
+ and braille interfaces), beyond the current emphasis on colorizing. - FM
+1997-08-02
+* The cookie pre-draft has been adopted as an IETF ID:
+ ftp://ds.internic.net/internet-drafts/draft-ietf-http-state-man-mec-03.txt
+ so the code for combining Set-Cookie and Set-Cookie2 headers has been
+ eliminated in LYCookie.c (see mods for 1997-07-31). - FM
1997-08-01
* Fixed typos in LYCookie.c. - FM
1997-07-31
diff --git a/LYMessages_en.h b/LYMessages_en.h
index 02ffa8d4..e1154122 100644
--- a/LYMessages_en.h
+++ b/LYMessages_en.h
@@ -501,10 +501,13 @@
#define UNSUPPORTED_DATA_URL "Unsupported data: URL! Use SHOWINFO, for now."
#define ILLEGAL_REDIRECTION_URL "Illegal redirection URL received from server!"
#define SERVER_ASKED_FOR_REDIRECTION \
- "Server asked for redirection of POST content to"
+ "Server asked for %d redirection of POST content to"
#define PROCEED_GET_CANCEL "P)roceed, use G)ET or C)ancel "
-#define ADVANCED_POST_REDIRECT \
+#define PROCEED_OR_CANCEL "P)roceed, or C)ancel "
+#define ADVANCED_POST_GET_REDIRECT \
"Redirection of POST content. P)roceed, see U)RL, use G)ET or C)ancel"
+#define ADVANCED_POST_REDIRECT \
+ "Redirection of POST content. P)roceed, see U)RL, or C)ancel"
#define CONFIRM_POST_RESUBMISSION \
"Document from Form with POST content. Resubmit?"
#define CONFIRM_POST_DOC_HEAD \
@@ -598,9 +601,10 @@
#define PROMTING_TO_ALLOW_COOKIES "'P'rompting to allow from domain '%s'."
#define DELETE_ALL_COOKIES_IN_DOMAIN "Delete all cookies in this domain?"
#define ALL_COOKIES_EATEN "All of the cookies in the jar have been eaten!"
-#define PORT_INVALID "URL contains an invalid port number."
#define PORT_NINETEEN_INVALID "Port 19 not permitted in URLs."
#define PORT_TWENTYFIVE_INVALID "Port 25 not permitted in URLs."
+#define PORT_INVALID "Port %lu not permitted in URLs."
+#define URL_PORT_BAD "URL has a bad port field."
#define HTML_STACK_OVERRUN "Maximum nesting of HTML elements exceeded."
#define BAD_PARTIAL_REFERENCE "Bad partial reference! Stripping lead dots."
#define TRACELOG_OPEN_FAILED "Trace Log open failed. Trace off!."
diff --git a/Makefile.old b/Makefile.old
index ecdaba32..d47cf85b 100644
--- a/Makefile.old
+++ b/Makefile.old
@@ -313,6 +313,7 @@ SITE_DEFS = $(DIR_DEFS) $(RP_DEFS) -DEXP_CHARTRANS -DNSL_FORK -DLYNXCGI_LINKS -D
# (needed in SITE_DEFS *and* SITE_LYDEFS !)
# -DEXP_CHARTRANS_AUTOSWITCH also let lynx switch term mode(Linux console only)
# -DSLANG_MBCS_HACK prevent cutoff lines when using UTF8 console (slang only)
+# -DUSE_ZLIB To use some functions from zlib library if you have it.
#
# if you are linking to freeWAIS-0.202 or older, you should define this
# in MCFLAGS (SITE_DEFS)
diff --git a/WWW/Library/Implementation/HTAlert.h b/WWW/Library/Implementation/HTAlert.h
index ec1d2397..33d31f11 100644
--- a/WWW/Library/Implementation/HTAlert.h
+++ b/WWW/Library/Implementation/HTAlert.h
@@ -112,6 +112,7 @@ extern BOOL HTConfirmCookie PARAMS((
** ----------------------------
** On entry,
** redirecting_url is the Location.
+** server_status is the server status code.
**
** On exit,
** Returns 0 on cancel,
@@ -119,7 +120,8 @@ extern BOOL HTConfirmCookie PARAMS((
** 303 for redirect as GET without content
*/
extern int HTConfirmPostRedirect PARAMS((
- CONST char * redirecting_url));
+ CONST char * redirecting_url,
+ int server_status));
/*
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index 49ef2090..397c3684 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -949,8 +949,8 @@ PUBLIC void HTAnchor_setRevTitle ARGS2(
}
/* Suggested filename handling. - FM
-** (will be loaded if we had a Content-disposition
-** header with file; filename=name.suffix)
+** (will be loaded if we had a Content-Disposition
+** header or META element with filename=name.suffix)
*/
PUBLIC CONST char * HTAnchor_SugFname ARGS1(
HTParentAnchor *, me)
@@ -958,6 +958,24 @@ PUBLIC CONST char * HTAnchor_SugFname ARGS1(
return me ? me->SugFname : NULL;
}
+/* Content-Encoding handling. - FM
+** (will be loaded if we had a Content-Encoding
+** header.)
+*/
+PUBLIC CONST char * HTAnchor_content_encoding ARGS1(
+ HTParentAnchor *, me)
+{
+ return me ? me->content_encoding : NULL;
+}
+
+/* Content-Type handling. - FM
+*/
+PUBLIC CONST char * HTAnchor_content_type ARGS1(
+ HTParentAnchor *, me)
+{
+ return me ? me->content_type : NULL;
+}
+
/* Last-Modified header handling. - FM
*/
PUBLIC CONST char * HTAnchor_last_modified ARGS1(
diff --git a/WWW/Library/Implementation/HTAnchor.h b/WWW/Library/Implementation/HTAnchor.h
index 052290cf..8818b36d 100644
--- a/WWW/Library/Implementation/HTAnchor.h
+++ b/WWW/Library/Implementation/HTAnchor.h
@@ -313,12 +313,24 @@ extern void HTAnchor_setRevTitle PARAMS((
CONST char * title));
/* Suggested filename handling. - FM
-** (will be loaded if we had a Content-disposition
-** header with file; filename=name.suffix)
+** (will be loaded if we had a Content-Disposition
+** header or META element with filename=name.suffix)
*/
extern CONST char * HTAnchor_SugFname PARAMS((
HTParentAnchor * me));
+/* Content-Type handling. - FM
+*/
+extern CONST char * HTAnchor_content_type PARAMS((
+ HTParentAnchor * me));
+
+/* Content-Encoding handling. - FM
+** (will be loaded if we had a Content-Encoding
+** header.)
+*/
+extern CONST char * HTAnchor_content_encoding PARAMS((
+ HTParentAnchor * me));
+
/* Last-Modified header handling. - FM
*/
extern CONST char * HTAnchor_last_modified PARAMS((
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 99f0cc41..53f082ab 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -705,7 +705,8 @@ PUBLIC HTFormat HTFileFormat ARGS2(
if (!HTSuffixes)
HTFileInit();
#endif /* !NO_INIT */
- *pencoding = NULL;
+ if (pencoding)
+ *pencoding = NULL;
lf = strlen(filename);
n = HTList_count(HTSuffixes);
for (i = 0; i < n; i++) {
@@ -714,7 +715,8 @@ PUBLIC HTFormat HTFileFormat ARGS2(
ls = strlen(suff->suffix);
if ((ls <= lf) && 0 == strcasecomp(suff->suffix, filename + lf - ls)) {
int j;
- *pencoding = suff->encoding;
+ if (pencoding)
+ *pencoding = suff->encoding;
if (suff->rep) {
#ifdef VMS
if (semicolon != NULL)
@@ -750,7 +752,7 @@ PUBLIC HTFormat HTFileFormat ARGS2(
/*
** Set default encoding unless found with suffix already.
*/
- if (!*pencoding)
+ if (pencoding && !*pencoding)
*pencoding = suff->encoding ? suff->encoding
: HTAtom_for("binary");
#ifdef VMS
@@ -772,7 +774,6 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
HTFormat, format,
HTParentAnchor *, anchor,
int, default_LYhndl)
-
{
char *cp = NULL, *cp1, *cp2, *cp3 = NULL, *cp4;
BOOL chartrans_ok = FALSE;
@@ -794,9 +795,9 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
cp2++;
#ifdef EXP_CHARTRANS
StrAllocCopy(cp3, cp2); /* copy to mutilate more */
- for (cp4=cp3; (*cp4 != '\0' && *cp4 != '"' &&
- *cp4 != ';' && *cp4 != ':' &&
- !WHITE(*cp4)); cp4++) {
+ for (cp4 = cp3; (*cp4 != '\0' && *cp4 != '"' &&
+ *cp4 != ';' && *cp4 != ':' &&
+ !WHITE(*cp4)); cp4++) {
; /* do nothing */
}
*cp4 = '\0';
@@ -813,29 +814,29 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
}
}
if (UCCanTranslateFromTo(chndl, current_char_set)) {
- chartrans_ok = YES;
- *cp1 = '\0';
- format = HTAtom_for(cp);
- StrAllocCopy(anchor->charset, cp4);
- HTAnchor_setUCInfoStage(anchor, chndl,
- UCT_STAGE_MIME, UCT_SETBY_MIME);
+ chartrans_ok = YES;
+ *cp1 = '\0';
+ format = HTAtom_for(cp);
+ StrAllocCopy(anchor->charset, cp4);
+ HTAnchor_setUCInfoStage(anchor, chndl,
+ UCT_STAGE_MIME, UCT_SETBY_MIME);
} else if (chndl < 0) {
/*
** Got something but we don't recognize it.
*/
- chndl = UCLYhndl_for_unrec;
+ chndl = UCLYhndl_for_unrec;
if (UCCanTranslateFromTo(chndl, current_char_set)) {
- chartrans_ok = YES;
- HTAnchor_setUCInfoStage(anchor, chndl,
- UCT_STAGE_MIME, UCT_SETBY_DEFAULT);
- }
- }
- FREE(cp3);
- if (chartrans_ok) {
+ chartrans_ok = YES;
+ HTAnchor_setUCInfoStage(anchor, chndl,
+ UCT_STAGE_MIME, UCT_SETBY_DEFAULT);
+ }
+ }
+ FREE(cp3);
+ if (chartrans_ok) {
LYUCcharset *p_in = HTAnchor_getUCInfoStage(anchor,
- UCT_STAGE_MIME);
+ UCT_STAGE_MIME);
LYUCcharset *p_out = HTAnchor_setUCInfoStage(anchor,
- current_char_set,
+ current_char_set,
UCT_STAGE_HTEXT,
UCT_SETBY_DEFAULT);
if (!p_out) {
@@ -861,7 +862,7 @@ PUBLIC HTFormat HTCharsetFormat ARGS3(
UCT_SETBY_DEFAULT);
}
if (!(p_in->enc & UCT_ENC_CJK) &&
- (p_in->codepoints & UCT_CP_SUBSETOF_LAT1)){
+ (p_in->codepoints & UCT_CP_SUBSETOF_LAT1)) {
HTCJK = NOCJK;
} else if (chndl == current_char_set) {
HTPassEightBitRaw = TRUE;
@@ -1421,6 +1422,10 @@ PUBLIC int HTLoadFile ARGS4(
#else
extern char *list_format;
#endif /* VMS */
+#ifdef USE_ZLIB
+ gzFile gzfp;
+ BOOL use_gzread = NO;
+#endif /* USE_ZLIB */
/*
** Reduce the filename to a basic form (hopefully unique!).
@@ -1436,11 +1441,11 @@ PUBLIC int HTLoadFile ARGS4(
if (strcmp("ftp", access) == 0 ||
(strcmp("localhost", nodename) != 0 &&
#ifdef VMS
- strcasecomp(nodename, HTHostName()) != 0))
+ strcasecomp(nodename, HTHostName()) != 0
#else
- strcmp(nodename, HTHostName()) != 0))
+ strcmp(nodename, HTHostName()) != 0
#endif /* VMS */
- {
+ )) {
FREE(newname);
FREE(filename);
FREE(nodename);
@@ -1540,7 +1545,6 @@ PUBLIC int HTLoadFile ARGS4(
int len;
char *cp = NULL;
char *semicolon = NULL;
- int status;
if (HTEditable(vmsname)) {
HTAtom * put = HTAtom_for("PUT");
@@ -1588,7 +1592,20 @@ PUBLIC int HTLoadFile ARGS4(
UCLYhndl_HTFile_for_unspec);
StrAllocCopy(anchor->content_type, format->name);
StrAllocCopy(anchor->content_encoding, "x-gzip");
+#ifdef USE_ZLIB
+ if (strcmp(format_out->name, "www/download") != 0) {
+ fclose(fp);
+ gzfp = gzopen(localname, "rb");
+
+ if (TRACE)
+ fprintf(stderr,
+ "HTLoadFile: gzopen of `%s' gives %p\n",
+ localname, (void*)gzfp);
+ use_gzread = YES;
+ }
+#else /* USE_ZLIB */
format = HTAtom_for("www/compressed");
+#endif /* USE_ZLIB */
}
}
}
@@ -1596,8 +1613,43 @@ PUBLIC int HTLoadFile ARGS4(
*semicolon = ';';
FREE(filename);
FREE(nodename);
- status = HTParseFile(format, format_out, anchor, fp, sink);
- fclose(fp);
+#ifdef USE_ZLIB
+ if (use_gzread) {
+ if (gzfp) {
+ char * sugfname = NULL;
+ if (anchor->SugFname) {
+ StrAllocCopy(sugfname, anchor->SugFname);
+ } else {
+ char * anchor_path = HTParse(anchor->address, "",
+ PARSE_PATH + PARSE_PUNCTUATION);
+ char * lastslash;
+ HTUnEscape(anchor_path);
+ lastslash = strrchr(anchor_path, '/');
+ if (lastslash)
+ StrAllocCopy(sugfname, lastslash + 1);
+ FREE(anchor_path);
+ }
+ FREE(anchor->content_encoding);
+ if (sugfname && *sugfname)
+ HTCheckFnameForCompression(&sugfname, anchor,
+ TRUE);
+ if (sugfname && *sugfname)
+ StrAllocCopy(anchor->SugFname, sugfname);
+ FREE(sugfname);
+ status = HTParseGzFile(format, format_out,
+ anchor,
+ gzfp, sink);
+ } else {
+ status = HTLoadError(NULL,
+ -(HT_ERROR),
+ "Could not open file for decompression!");
+ }
+ } else
+#endif /* USE_GZREAD */
+ {
+ status = HTParseFile(format, format_out, anchor, fp, sink);
+ fclose(fp);
+ }
return status;
} /* If successfull open */
FREE(filename);
@@ -1635,7 +1687,7 @@ PUBLIC int HTLoadFile ARGS4(
STRUCT_DIRENT * dirbuf;
float best = NO_VALUE_FOUND; /* So far best is bad */
HTFormat best_rep = NULL; /* Set when rep found */
- STRUCT_DIRENT best_dirbuf; /* Best dir entry so far */
+ char * best_name = NULL; /* Best dir entry so far */
char *base = strrchr(localname, '/');
int baselen;
@@ -1665,10 +1717,55 @@ forget_multi:
#endif
if ((int)strlen(dirbuf->d_name) > baselen && /* Match? */
!strncmp(dirbuf->d_name, base, baselen)) {
- HTFormat rep = HTFileFormat(dirbuf->d_name, &encoding);
+ HTFormat rep = HTFileFormat(dirbuf->d_name, NULL);
+ float filevalue = HTFileValue(dirbuf->d_name);
float value = HTStackValue(rep, format_out,
- HTFileValue(dirbuf->d_name),
- 0.0 /* @@@@@@ */);
+ filevalue,
+ 0L /* @@@@@@ */);
+ if (value <= 0.0) {
+ char * cp = NULL;
+ int len = strlen(dirbuf->d_name);
+ if (len > 2 &&
+ dirbuf->d_name[len - 1] == 'Z' &&
+ dirbuf->d_name[len - 2] == '.') {
+ StrAllocCopy(cp, dirbuf->d_name);
+ cp[len - 2] = '\0';
+ format = HTFileFormat(cp, NULL);
+ FREE(cp);
+ value = HTStackValue(format, format_out,
+ filevalue, 0);
+ if (value <= 0.0) {
+ format = HTAtom_for("application/x-compressed");
+ value = HTStackValue(format, format_out,
+ filevalue, 0);
+ }
+ if (value <= 0.0) {
+ format = HTAtom_for("www/compressed");
+ value = HTStackValue(format, format_out,
+ filevalue, 0);
+ }
+ } else if ((len > 3) &&
+ !strcasecomp((char *)&dirbuf->d_name[len - 2],
+ "gz") &&
+ dirbuf->d_name[len - 3] == '.') {
+ StrAllocCopy(cp, dirbuf->d_name);
+ cp[len - 3] = '\0';
+ format = HTFileFormat(cp, NULL);
+ FREE(cp);
+ value = HTStackValue(format, format_out,
+ filevalue, 0);
+ if (value <= 0.0) {
+ format = HTAtom_for("application/x-gzip");
+ value = HTStackValue(format, format_out,
+ filevalue, 0);
+ }
+ if (value <= 0.0) {
+ format = HTAtom_for("www/compressed");
+ value = HTStackValue(format, format_out,
+ filevalue, 0);
+ }
+ }
+ }
if (value != NO_VALUE_FOUND) {
if (TRACE)
fprintf(stderr,
@@ -1677,7 +1774,7 @@ forget_multi:
if (value > best) {
best_rep = rep;
best = value;
- best_dirbuf = *dirbuf;
+ StrAllocCopy(best_name, dirbuf->d_name);
}
} /* if best so far */
} /* if match */
@@ -1689,8 +1786,9 @@ forget_multi:
format = best_rep;
base[-1] = '/'; /* Restore directory name */
base[0] = '\0';
- StrAllocCat(localname, best_dirbuf.d_name);
- goto open_file;
+ StrAllocCat(localname, best_name);
+ FREE(best_name);
+ /* goto open_file; */ /* Nope - might be a directory - kw */
} else { /* If not found suitable file */
FREE(localname);
@@ -1711,10 +1809,11 @@ forget_multi:
** to point to the current directory being read.
*/
#ifdef _WINDOWS
- if (!exists(localname)) {
+ if (!exists(localname))
#else
- if (stat(localname,&dir_info) == -1) { /* get file information */
+ if (stat(localname,&dir_info) == -1) /* get file information */
#endif
+ {
/* if can't read file information */
if (TRACE)
fprintf(stderr, "HTLoadFile: can't stat %s\n", localname);
@@ -1966,6 +2065,11 @@ forget_multi:
"Subirectories:" : "Files:");
END(HTML_EM);
}
+ END(HTML_H2);
+#ifndef LONG_LIST
+ START(HTML_DIR);
+#endif /* !LONG_LIST */
+ }
#else
if (state != *(char *)(HTBTree_object(
next_element))) {
@@ -1981,12 +2085,12 @@ forget_multi:
PUTS(state == 'D' ?
"Subdirectories:" : "Files:");
END(HTML_EM);
-#endif /* DIRED_SUPPORT */
END(HTML_H2);
#ifndef LONG_LIST
START(HTML_DIR);
#endif /* !LONG_LIST */
}
+#endif /* DIRED_SUPPORT */
#ifndef LONG_LIST
START(HTML_LI);
#endif /* !LONG_LIST */
@@ -2053,7 +2157,6 @@ open_file:
if (fp) { /* Good! */
int len;
char *cp = NULL;
- int status;
if (HTEditable(localname)) {
HTAtom * put = HTAtom_for("PUT");
@@ -2089,13 +2192,61 @@ open_file:
UCLYhndl_HTFile_for_unspec);
StrAllocCopy(anchor->content_type, format->name);
StrAllocCopy(anchor->content_encoding, "x-gzip");
+#ifdef USE_ZLIB
+ if (strcmp(format_out->name, "www/download") != 0) {
+ fclose(fp);
+ gzfp = gzopen(localname, "rb");
+
+ if (TRACE)
+ fprintf(stderr,
+ "HTLoadFile: gzopen of `%s' gives %p\n",
+ localname, (void*)gzfp);
+ use_gzread = YES;
+ }
+#else /* USE_ZLIB */
format = HTAtom_for("www/compressed");
+#endif /* USE_ZLIB */
}
}
FREE(localname);
FREE(nodename);
- status = HTParseFile(format, format_out, anchor, fp, sink);
- fclose(fp);
+#ifdef USE_ZLIB
+ if (use_gzread) {
+ if (gzfp) {
+ char * sugfname = NULL;
+ if (anchor->SugFname) {
+ StrAllocCopy(sugfname, anchor->SugFname);
+ } else {
+ char * anchor_path = HTParse(anchor->address, "",
+ PARSE_PATH + PARSE_PUNCTUATION);
+ char * lastslash;
+ HTUnEscape(anchor_path);
+ lastslash = strrchr(anchor_path, '/');
+ if (lastslash)
+ StrAllocCopy(sugfname, lastslash + 1);
+ FREE(anchor_path);
+ }
+ FREE(anchor->content_encoding);
+ if (sugfname && *sugfname)
+ HTCheckFnameForCompression(&sugfname, anchor,
+ TRUE);
+ if (sugfname && *sugfname)
+ StrAllocCopy(anchor->SugFname, sugfname);
+ FREE(sugfname);
+ status = HTParseGzFile(format, format_out,
+ anchor,
+ gzfp, sink);
+ } else {
+ status = HTLoadError(NULL,
+ -(HT_ERROR),
+ "Could not open file for decompression!");
+ }
+ } else
+#endif /* USE_GZREAD */
+ {
+ status = HTParseFile(format, format_out, anchor, fp, sink);
+ fclose(fp);
+ }
return status;
} /* If succesfull open */
} /* scope of fp */
diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c
index c8bda5de..b5f8584d 100644
--- a/WWW/Library/Implementation/HTFormat.c
+++ b/WWW/Library/Implementation/HTFormat.c
@@ -661,6 +661,99 @@ PUBLIC int HTFileCopy ARGS2(
return rv;
}
+#ifdef USE_ZLIB
+/* Push data from a gzip file pointer down a stream
+** -------------------------------------
+**
+** This routine is responsible for creating and PRESENTING any
+** graphic (or other) objects described by the file.
+**
+**
+*/
+PRIVATE int HTGzFileCopy ARGS2(
+ gzFile, gzfp,
+ HTStream*, sink)
+{
+ HTStreamClass targetClass;
+ char line[256];
+ int status, bytes = 0, nreads = 0, nprogr = 0;
+ int gzerrnum;
+ int rv = HT_OK;
+
+ /* Push the data down the stream
+ */
+ targetClass = *(sink->isa); /* Copy pointers to procedures */
+
+ /* read and inflate gzipped file, and push binary down sink
+ */
+ for (;;) {
+ status = gzread(gzfp, input_buffer, INPUT_BUFFER_SIZE);
+ nreads++;
+ if (status <= 0) { /* EOF or error */
+ if (status == 0) {
+ rv = HT_LOADED;
+ break;
+ }
+ if (TRACE) {
+ fprintf(stderr,
+ "HTGzFileCopy: Read error, gzread returns %d\n",
+ status);
+ fprintf(stderr,
+ "gzerror : %s\n",
+ gzerror(gzfp, &gzerrnum));
+ if (gzerrnum == Z_ERRNO)
+ perror("gzerror ");
+ }
+ if (bytes) {
+ rv = HT_PARTIAL_CONTENT;
+ } else {
+ rv = -1;
+ }
+ break;
+ }
+ (*targetClass.put_block)(sink, input_buffer, status);
+
+ bytes += status;
+ if (nreads >= 100) {
+ /*
+ ** Show progress messages for local files, and check for
+ ** user interruption. Start doing so only after a certain
+ ** number of reads have been done, and don't update it on
+ ** every read (normally reading in a local file should be
+ ** speedy). - KW
+ */
+ if (nprogr == 0) {
+ if (bytes < 1024000) {
+ sprintf(line,
+ "Read %d uncompressed bytes of data.", bytes);
+ } else {
+ sprintf(line, "Read %d uncompressed KB of data. %s",
+ bytes/1024,
+ "(Press 'z' to abort.)");
+ }
+ HTProgress(line);
+ if (HTCheckForInterrupt()) {
+ _HTProgress ("Data transfer interrupted.");
+ if (bytes) {
+ rv = HT_INTERRUPTED;
+ } else {
+ rv = -1;
+ }
+ break;
+ }
+ nprogr++;
+ } else if (nprogr == 25) {
+ nprogr = 0;
+ } else {
+ nprogr++;
+ }
+ }
+ } /* next bufferload */
+
+ return rv;
+}
+#endif /* USE_ZLIB */
+
/* Push data from a socket down a stream STRIPPING CR
** --------------------------------------------------
**
@@ -807,6 +900,78 @@ PUBLIC int HTParseFile ARGS5(
return HT_LOADED;
}
+#ifdef USE_ZLIB
+PRIVATE int HTCloseGzFile ARGS1(
+ gzFile, gzfp)
+{
+ int gzres;
+ if (gzfp == NULL)
+ return 0;
+ gzres = gzclose(gzfp);
+ if (TRACE) {
+ if (gzres == Z_ERRNO) {
+ perror("gzclose ");
+ } else if (gzres != Z_OK) {
+ fprintf(stderr, "gzclose : error number %d\n", gzres);
+ }
+ }
+ return(gzres);
+}
+
+PUBLIC int HTParseGzFile ARGS5(
+ HTFormat, rep_in,
+ HTFormat, format_out,
+ HTParentAnchor *, anchor,
+ gzFile, gzfp,
+ HTStream*, sink)
+{
+ HTStream * stream;
+ HTStreamClass targetClass;
+ int rv;
+
+ stream = HTStreamStack(rep_in,
+ format_out,
+ sink , anchor);
+
+ if (!stream) {
+ char buffer[1024]; /* @@@@@@@@ */
+ extern char LYCancelDownload;
+ HTCloseGzFile(gzfp);
+ if (LYCancelDownload) {
+ LYCancelDownload = FALSE;
+ return -1;
+ }
+ sprintf(buffer, "Sorry, can't convert from %s to %s.",
+ HTAtom_name(rep_in), HTAtom_name(format_out));
+ if (TRACE)
+ fprintf(stderr, "HTFormat(in HTParseGzFile): %s\n", buffer);
+ return HTLoadError(sink, 501, buffer);
+ }
+
+ /* Push the data down the stream
+ **
+ ** @@ Bug: This decision ought to be made based on "encoding"
+ ** rather than on content-type. @@@ When we handle encoding.
+ ** The current method smells anyway.
+ */
+ targetClass = *(stream->isa); /* Copy pointers to procedures */
+ rv = HTGzFileCopy(gzfp, stream);
+ if (rv == -1 || rv == HT_INTERRUPTED) {
+ (*targetClass._abort)(stream, NULL);
+ } else {
+ (*targetClass._free)(stream);
+ }
+
+ HTCloseGzFile(gzfp);
+ if (rv == -1)
+ return HT_NO_DATA;
+ else if (rv == HT_INTERRUPTED || (rv > 0 && rv != HT_LOADED))
+ return HT_PARTIAL_CONTENT;
+ else
+ return HT_LOADED;
+}
+#endif /* USE_ZLIB */
+
/* Converter stream: Network Telnet to internal character text
** -----------------------------------------------------------
**
diff --git a/WWW/Library/Implementation/HTFormat.h b/WWW/Library/Implementation/HTFormat.h
index 24972f06..812e2fc3 100644
--- a/WWW/Library/Implementation/HTFormat.h
+++ b/WWW/Library/Implementation/HTFormat.h
@@ -359,6 +359,26 @@ extern int HTParseFile PARAMS((
FILE *fp,
HTStream* sink));
+#ifdef USE_ZLIB
+
+#ifdef USE_ZLIB
+#include <zlib.h>
+#endif /* USE_ZLIB */
+/*
+HTParseGzFile: Parse a gzipped File through a file pointer
+
+ This routine is called by protocols modules to load an object. uses HTStreamStack and
+ HTGzFileCopy . Returns HT_LOADED if succesful, <0 if not.
+ */
+extern int HTParseGzFile PARAMS((
+ HTFormat format_in,
+ HTFormat format_out,
+ HTParentAnchor *anchor,
+ gzFile gzfp,
+ HTStream* sink));
+
+#endif /* USE_ZLIB */
+
/*
HTNetToText: Convert Net ASCII to local representation
diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c
index 2b9e31e4..60645dee 100644
--- a/WWW/Library/Implementation/HTMIME.c
+++ b/WWW/Library/Implementation/HTMIME.c
@@ -972,7 +972,7 @@ PRIVATE void HTMIME_put_character ARGS2(
} /* switch on character */
break;
- case miS: /* Check for 'a; or 'e' */
+ case miS: /* Check for 'a' or 'e' */
switch (c) {
case 'a':
case 'A':
@@ -1565,25 +1565,24 @@ PRIVATE void HTMIME_put_character ARGS2(
*/
StrAllocCopy(me->anchor->content_disposition, me->value);
/*
- ** If it includes file; filename=name.suffix
- ** load the me->SugFname element. - FM
+ ** It's not clear yet from existing RFCs and IDs
+ ** whether we should be looking for file;, attachment;,
+ ** and/or inline; before the filename=value, so we'll
+ ** just search for "filename" followed by '=' and just
+ ** hope we get the intended value. It is purely a
+ ** suggested name, anyway. - FM
*/
cp = me->anchor->content_disposition;
- while (*cp != '\0' && strncasecomp(cp, "file;", 5))
- cp++;
- if (*cp == '\0')
- break;
- cp += 5;
- while (*cp != '\0' && WHITE(*cp))
+ while (*cp != '\0' && strncasecomp(cp, "filename", 8))
cp++;
if (*cp == '\0')
break;
- while (*cp != '\0' && strncasecomp(cp, "filename", 8))
+ cp += 8;
+ while ((*cp != '\0') && (WHITE(*cp) || *cp == '='))
cp++;
if (*cp == '\0')
break;
- cp += 8;
- while (*cp == ' ' || *cp == '=')
+ while (*cp != '\0' && WHITE(*cp))
cp++;
if (*cp == '\0')
break;
diff --git a/WWW/Library/Implementation/HTML.h b/WWW/Library/Implementation/HTML.h
index 2aaa8c0f..7480b678 100644
--- a/WWW/Library/Implementation/HTML.h
+++ b/WWW/Library/Implementation/HTML.h
@@ -88,8 +88,8 @@ struct _HTStructured {
* Used for nested lists. - FM
*/
int List_Nesting_Level; /* counter for list nesting level */
- int OL_Counter[7]; /* counter for ordered lists */
- char OL_Type[7]; /* types for ordered lists */
+ int OL_Counter[12]; /* counter for ordered lists */
+ char OL_Type[12]; /* types for ordered lists */
int Last_OL_Count; /* last count in ordered lists */
char Last_OL_Type; /* last type in ordered lists */
diff --git a/WWW/Library/Implementation/HTNews.c b/WWW/Library/Implementation/HTNews.c
index 21da80d8..bcf2993e 100644
--- a/WWW/Library/Implementation/HTNews.c
+++ b/WWW/Library/Implementation/HTNews.c
@@ -78,6 +78,7 @@ PRIVATE HTStructured * target; /* The output sink */
PRIVATE HTStructuredClass targetClass; /* Copy of fn addresses */
PRIVATE HTParentAnchor *node_anchor; /* Its anchor */
PRIVATE int diagnostic; /* level: 0=none 2=source */
+PRIVATE HTList *NNTP_AuthInfo = NULL; /* AUTHINFO database */
#define PUTC(c) (*targetClass.put_character)(target, c)
#define PUTS(s) (*targetClass.put_string)(target, s)
@@ -86,13 +87,42 @@ PRIVATE int diagnostic; /* level: 0=none 2=source */
#define MAYBE_END(e) if (HTML_dtd.tags[e].contents != SGML_EMPTY) \
(*targetClass.end_element)(target, e, 0)
+typedef struct _NNTPAuth {
+ char * host;
+ char * user;
+ char * pass;
+} NNTPAuth;
+
PRIVATE void free_news_globals NOARGS
{
+ if (s >= 0) {
+ NEWS_NETCLOSE(s);
+ s = -1;
+ }
FREE(HTNewsHost);
FREE(NewsHost);
FREE(NewsHREF);
}
+PRIVATE void free_NNTP_AuthInfo NOARGS
+{
+ HTList *cur = NNTP_AuthInfo;
+ NNTPAuth *auth = NULL;
+
+ if (!cur)
+ return;
+
+ while (NULL != (auth = (NNTPAuth *)HTList_nextObject(cur))) {
+ FREE(auth->host);
+ FREE(auth->user);
+ FREE(auth->pass);
+ FREE(auth);
+ }
+ HTList_delete(NNTP_AuthInfo);
+ NNTP_AuthInfo = NULL;
+ return;
+}
+
PUBLIC CONST char * HTGetNewsHost NOARGS
{
return HTNewsHost;
@@ -260,6 +290,239 @@ PRIVATE BOOL match ARGS2 (CONST char *,unknown, CONST char *,template)
return (BOOL)(*t == 0); /* OK if end of template */
}
+typedef enum {
+ NNTPAUTH_ERROR = 0, /* general failure */
+ NNTPAUTH_OK = 281, /* authenticated successfully */
+ NNTPAUTH_CLOSE = 502 /* server probably closed connection */
+} NNTPAuthResult;
+/*
+** This function handles nntp authentication. - FM
+*/
+PRIVATE NNTPAuthResult HTHandleAuthInfo ARGS1(
+ char *, host)
+{
+ HTList *cur = NULL;
+ NNTPAuth *auth = NULL;
+ char *UserName = NULL;
+ char *PassWord = NULL;
+ char *msg = NULL;
+ char buffer[512];
+ int status, tries;
+ extern BOOL dump_output_immediately;
+
+ /*
+ ** Make sure we have an interactive user and a host. - FM
+ */
+ if (dump_output_immediately || !(host && *host))
+ return NNTPAUTH_ERROR;
+
+ /*
+ ** Check for an existing authorization entry. - FM
+ */
+ if (NNTP_AuthInfo != NULL) {
+ cur = NNTP_AuthInfo;
+ while (NULL != (auth = (NNTPAuth *)HTList_nextObject(cur))) {
+ if (!strcmp(auth->host, host)) {
+ UserName = auth->user;
+ PassWord = auth->pass;
+ break;
+ }
+ }
+ } else {
+ NNTP_AuthInfo = HTList_new();
+ atexit(free_NNTP_AuthInfo);
+ }
+
+ /*
+ ** Handle the username. - FM
+ */
+ buffer[511] = '\0';
+ tries = 3;
+
+ while (tries) {
+ if (UserName == NULL) {
+ if ((msg = (char *)calloc(1, (strlen(host) + 30))) == NULL) {
+ outofmem(__FILE__, "HTHandleAuthInfo");
+ }
+ sprintf(msg, "Username for news host '%s':", host);
+ UserName = HTPrompt(msg, NULL);
+ FREE(msg);
+ if (!(UserName && *UserName)) {
+ FREE(UserName);
+ return NNTPAUTH_ERROR;
+ }
+ }
+ sprintf(buffer, "AUTHINFO USER %.*s%c%c", 495, UserName, CR, LF);
+ if ((status = response(buffer)) < 0) {
+ if (status == HT_INTERRUPTED)
+ _HTProgress("Connection interrupted.");
+ else
+ HTAlert("Connection closed ???");
+ if (auth) {
+ if (auth->user != UserName) {
+ FREE(auth->user);
+ auth->user = UserName;
+ }
+ } else {
+ FREE(UserName);
+ }
+ return NNTPAUTH_CLOSE;
+ }
+ if (status == 281) {
+ /*
+ ** Username is OK and no Password is required. - FM
+ */
+ if (auth) {
+ if (auth->user != UserName) {
+ FREE(auth->user);
+ auth->user = UserName;
+ }
+ } else {
+ if ((auth =
+ (NNTPAuth *)calloc(1, sizeof(NNTPAuth))) != NULL) {
+ StrAllocCopy(auth->host, host);
+ auth->user = UserName;
+ HTList_appendObject(NNTP_AuthInfo, auth);
+ }
+ }
+ return NNTPAUTH_OK;
+ }
+ if (status != 381) {
+ /*
+ ** Not a request for the password, so it must be an error. - FM
+ */
+ HTAlert(response_text);
+ tries--;
+ if ((tries > 0) && HTConfirm("Change username?")) {
+ if (!auth || auth->user != UserName) {
+ FREE(UserName);
+ }
+ if ((UserName = HTPrompt("Username:", UserName)) != NULL &&
+ *UserName) {
+ continue;
+ }
+ }
+ if (auth) {
+ if (auth->user != UserName) {
+ FREE(auth->user);
+ }
+ FREE(auth->pass);
+ }
+ FREE(UserName);
+ return NNTPAUTH_ERROR;
+ }
+ break;
+ }
+
+ if (status == 381) {
+ /*
+ ** Username is OK, and a password is required. - FM
+ */
+ tries = 3;
+ while (tries) {
+ if (PassWord == NULL) {
+ if ((msg = (char *)calloc(1, (strlen(host) + 30))) == NULL) {
+ outofmem(__FILE__, "HTHandleAuthInfo");
+ }
+ sprintf(msg, "Password for news host '%s':", host);
+ PassWord = HTPromptPassword(msg);
+ FREE(msg);
+ if (!(PassWord && *PassWord)) {
+ FREE(PassWord);
+ return NNTPAUTH_ERROR;
+ }
+ }
+ sprintf(buffer, "AUTHINFO PASS %.*s%c%c", 495, PassWord, CR, LF);
+ if ((status = response(buffer)) < 0) {
+ if (status == HT_INTERRUPTED) {
+ _HTProgress("Connection interrupted.");
+ } else {
+ HTAlert("Connection closed ???");
+ }
+ if (auth) {
+ if (auth->user != UserName) {
+ FREE(auth->user);
+ auth->user = UserName;
+ }
+ if (auth->pass != PassWord) {
+ FREE(auth->pass);
+ auth->pass = PassWord;
+ }
+ } else {
+ FREE(UserName);
+ FREE(PassWord);
+ }
+ return NNTPAUTH_CLOSE;
+ }
+ if (status == 502) {
+ /*
+ * That's what INN's nnrpd returns.
+ * It closes the connection after this. - kw
+ */
+ HTAlert(response_text);
+ if (auth) {
+ if (auth->user == UserName)
+ UserName = NULL;
+ FREE(auth->user);
+ if (auth->pass == PassWord)
+ PassWord = NULL;
+ FREE(auth->pass);
+ }
+ FREE(UserName);
+ FREE(PassWord);
+ return NNTPAUTH_CLOSE;
+ }
+ if (status == 281) {
+ /*
+ ** Password is OK. - FM
+ */
+ if (auth) {
+ if (auth->user != UserName) {
+ FREE(auth->user);
+ auth->user = UserName;
+ }
+ if (auth->pass != PassWord) {
+ FREE(auth->pass);
+ auth->pass = PassWord;
+ }
+ } else {
+ if ((auth =
+ (NNTPAuth *)calloc(1, sizeof(NNTPAuth))) != NULL) {
+ StrAllocCopy(auth->host, host);
+ auth->user = UserName;
+ auth->pass = PassWord;
+ HTList_appendObject(NNTP_AuthInfo, auth);
+ }
+ }
+ return NNTPAUTH_OK;
+ }
+ /*
+ ** Show the error message and see if we should try again. - FM
+ */
+ HTAlert(response_text);
+ if (!auth || auth->pass != PassWord) {
+ FREE(PassWord);
+ } else {
+ PassWord = NULL;
+ }
+ tries--;
+ if ((tries > 0) && HTConfirm("Change password?")) {
+ continue;
+ }
+ if (auth) {
+ if (auth->user == UserName)
+ UserName = NULL;
+ FREE(auth->user);
+ FREE(auth->pass);
+ }
+ FREE(UserName);
+ break;
+ }
+ }
+
+ return NNTPAUTH_ERROR;
+}
+
/* Find Author's name in mail address
** ----------------------------------
**
@@ -1919,7 +2182,7 @@ PUBLIC int HTLoadNews ARGS4(
if (post_wanted || reply_wanted || spost_wanted || sreply_wanted) {
strcpy(command, "POST");
} else if (list_wanted) {
- strcpy(command, "LIST NEWSGROUPS");
+ sprintf(command, "XGTITLE %.*s", 249, p1);
} else if (group_wanted) {
char * slash = strchr(p1, '/');
strcpy(command, "GROUP ");
@@ -2170,10 +2433,10 @@ PUBLIC int HTLoadNews ARGS4(
} else {
/*
** Ensure reader mode, but don't bother checking the
- ** status for anything but HT_INERRUPTED, because if
- ** the reader mode command is not needed, the server
- ** probably return a 500, which is irrelevant at
- ** this point. - FM
+ ** status for anything but HT_INTERRUPTED or a 480
+ ** Authorization request, because if the reader mode
+ ** command is not needed, the server probably returned
+ ** a 500, which is irrelevant at this point. - FM
*/
char buffer[20];
@@ -2182,6 +2445,22 @@ PUBLIC int HTLoadNews ARGS4(
_HTProgress("Connection interrupted.");
break;
}
+ if (status == 480) {
+ NNTPAuthResult auth_result = HTHandleAuthInfo(NewsHost);
+ if (auth_result == NNTPAUTH_CLOSE) {
+ if (s != -1 && !(ProxyHost || ProxyHREF)) {
+ NEWS_NETCLOSE(s);
+ s = -1;
+ }
+ }
+ if (auth_result != NNTPAUTH_OK) {
+ break;
+ }
+ if ((status = response(buffer)) == HT_INTERRUPTED) {
+ _HTProgress("Connection interrupted.");
+ break;
+ }
+ }
}
Send_NNTP_command:
@@ -2196,12 +2475,41 @@ Send_NNTP_command:
break;
}
}
+ /*
+ * For some well known error responses which are expected
+ * to occur in normal use, break from the loop without retrying
+ * and without closing the connection. It is unlikely that
+ * these are leftovers from a timed-out connection (but we do
+ * some checks to see whether the response rorresponds to the
+ * last command), or that they will give anything else when
+ * automatically retried. - kw
+ */
+ if (status == 411 && group_wanted &&
+ !strncmp(command, "GROUP ", 6) &&
+ !strncasecomp(response_text + 3, " No such group ", 15) &&
+ !strcmp(response_text + 18, groupName)) {
+
+ HTAlert(response_text);
+ break;
+ } else if (status == 430 && !group_wanted && !list_wanted &&
+ !strncmp(command, "ARTICLE <", 9) &&
+ !strcasecomp(response_text + 3, " No such article")) {
+
+ HTAlert(response_text);
+ break;
+ }
if ((status/100) != 2 &&
- status != 340) {
- if (retries)
+ status != 340 &&
+ status != 480) {
+ if (retries) {
+ if (list_wanted && !strncmp(command, "XGTITLE", 7)) {
+ sprintf(command, "LIST NEWSGROUPS%c%c", CR, LF);
+ goto Send_NNTP_command;
+ }
HTAlert(response_text);
- else
+ } else {
_HTProgress(response_text);
+ }
NEWS_NETCLOSE(s);
s = -1;
/*
@@ -2215,7 +2523,36 @@ Send_NNTP_command:
/*
** Post or load a group, article, etc
*/
- if (post_wanted || reply_wanted || spost_wanted || sreply_wanted) {
+ if (status == 480) {
+ NNTPAuthResult auth_result;
+ /*
+ * Some servers return 480 for a failed XGTITLE. - FM
+ */
+ if (list_wanted && !strncmp(command, "XGTITLE", 7) &&
+ strstr(response_text, "uthenticat") == NULL &&
+ strstr(response_text, "uthor") == NULL) {
+ sprintf(command, "LIST NEWSGROUPS%c%c", CR, LF);
+ goto Send_NNTP_command;
+ }
+ /*
+ ** Handle Authorization. - FM
+ */
+ if ((auth_result = HTHandleAuthInfo(NewsHost)) == NNTPAUTH_OK) {
+ goto Send_NNTP_command;
+ } else if (auth_result == NNTPAUTH_CLOSE) {
+ if (s != -1 && !(ProxyHost || ProxyHREF)) {
+ NEWS_NETCLOSE(s);
+ s = -1;
+ }
+ if (retries < 1)
+ continue;
+ }
+ status = HT_NOT_LOADED;
+ } else if (post_wanted || reply_wanted ||
+ spost_wanted || sreply_wanted) {
+ /*
+ ** Handle posting of an article. - FM
+ */
if (status != 340) {
HTAlert("Cannot POST to this host.");
if (postfile) {
@@ -2232,9 +2569,15 @@ Send_NNTP_command:
FREE(postfile);
status = HT_NOT_LOADED;
} else if (list_wanted) {
+ /*
+ ** List available newsgroups. - FM
+ */
_HTProgress("Reading list of available newsgroups.");
status = read_list(ListArg);
} else if (group_wanted) {
+ /*
+ ** List articles in a news group. - FM
+ */
if (last < 0) {
/*
** We got one article number rather than a range
@@ -2252,6 +2595,9 @@ Send_NNTP_command:
_HTProgress("Reading list of articles in newsgroup.");
status = read_group(groupName, first, last);
} else {
+ /*
+ ** Get an article from a news group. - FM
+ */
_HTProgress("Reading news article.");
status = read_article();
}
@@ -2260,8 +2606,13 @@ Send_NNTP_command:
status = HT_LOADED;
}
if (!(post_wanted || reply_wanted ||
- spost_wanted || sreply_wanted))
- (*targetClass._free)(target);
+ spost_wanted || sreply_wanted)) {
+ if (status == HT_NOT_LOADED) {
+ (*targetClass._abort)(target, NULL);
+ } else {
+ (*targetClass._free)(target);
+ }
+ }
FREE(NewsHREF);
if (ProxyHREF) {
StrAllocCopy(NewsHost, ProxyHost);
diff --git a/WWW/Library/Implementation/HTStyle.h b/WWW/Library/Implementation/HTStyle.h
index 837251aa..99f57e54 100644
--- a/WWW/Library/Implementation/HTStyle.h
+++ b/WWW/Library/Implementation/HTStyle.h
@@ -104,7 +104,7 @@ typedef struct _HTStyle {
*/
HTFont font; /* Font id */
HTCoord fontSize; /* The size of font, not independent */
- HTColor color; /* text gray of current run */
+ HTColor color; /* text gray of current run */
int superscript; /* superscript (-sub) in points */
HTAnchor *anchor; /* Anchor id if any, else zero */
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index 98d21800..06c9ff03 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -325,9 +325,15 @@ PUBLIC int HTParseInet ARGS2(
struct hostent *phost; /* Pointer to host - See netdb.h */
if (!str) {
- if (TRACE)
- fprintf(stderr,
- "HTParseInet: Can't parse `NULL'.\n");
+ if (TRACE) {
+ fprintf(stderr, "HTParseInet: Can't parse `NULL'.\n");
+ }
+ return -1;
+ }
+ if (HTCheckForInterrupt()) {
+ if (TRACE) {
+ fprintf (stderr, "HTParseInet: INTERRUPTED for '%s'.\n", str);
+ }
return -1;
}
StrAllocCopy(host, str); /* Make a copy we can mutilate */
@@ -350,8 +356,11 @@ PUBLIC int HTParseInet ARGS2(
} else {
#ifdef SUPPRESS /* 1. crashes!?!. 2. Not recommended */
struct servent * serv = getservbyname(port, (char*)0);
- if (serv) sin->sin_port = serv->s_port;
- else if (TRACE) fprintf(stderr, "TCP: Unknown service %s\n", port);
+ if (serv) {
+ sin->sin_port = serv->s_port;
+ } else if (TRACE) {
+ fprintf(stderr, "TCP: Unknown service %s\n", port);
+ }
#endif /* SUPPRESS */
}
}
@@ -363,11 +372,11 @@ PUBLIC int HTParseInet ARGS2(
*/
sin->sdn_nam.n_len = min(DN_MAXNAML, strlen(host)); /* <=6 in phase 4 */
strncpy (sin->sdn_nam.n_name, host, sin->sdn_nam.n_len + 1);
- if (TRACE)
+ if (TRACE) {
fprintf(stderr,
"DECnet: Parsed address as object number %d on host %.6s...\n",
sin->sdn_objnum, host);
-
+ }
#else /* parse Internet host */
if (*host >= '0' && *host <= '9') { /* Test for numeric node address: */
@@ -404,8 +413,10 @@ PUBLIC int HTParseInet ARGS2(
FREE(host);
} else { /* Alphanumeric node name: */
#ifdef MVS /* Oustanding problem with crash in MVS gethostbyname */
- if (TRACE)
- fprintf(stderr, "HTTCP: Calling gethostbyname(%s)\n", host);
+ if (TRACE) {
+ fprintf(stderr,
+ "HTParseInet: Calling gethostbyname(%s)\n", host);
+ }
#endif /* MVS */
#ifdef NSL_FORK
@@ -462,8 +473,10 @@ PUBLIC int HTParseInet ARGS2(
** Abort if interrupt key pressed.
*/
if (HTCheckForInterrupt()) {
- if (TRACE)
- fprintf (stderr, "*** INTERRUPTED gethostbyname.\n");
+ if (TRACE) {
+ fprintf(stderr,
+ "HTParseInet: INTERRUPTED gethostbyname.\n");
+ }
kill(fpid , SIGKILL);
FREE(host);
close(pfd[0]);
@@ -475,26 +488,28 @@ PUBLIC int HTParseInet ARGS2(
*/
sleep(1);
}
- if (waitret <= 0)
+ if (waitret <= 0) {
waitret = waitpid(fpid, &cst1, WNOHANG);
+ }
if (TRACE) {
if (WIFEXITED(cst1)) {
fprintf(stderr,
- "NSL_FORK: Child %d exited, status 0x%x.\n",
+ "HTParseInet: NSL_FORK child %d exited, status 0x%x.\n",
(int)waitret, cst1);
} else if (WIFSIGNALED(cst1)) {
fprintf(stderr,
- "NSL_FORK: Child %d got signal, status 0x%x!\n",
+ "HTParseInet: NSL_FORK child %d got signal, status 0x%x!\n",
(int)waitret, cst1);
#ifdef WCOREDUMP
if (WCOREDUMP(cst1)) {
- fprintf(stderr,
- "NSL_FORK: Child %d dumped core!\n",(int)waitret);
+ fprintf(stderr,
+ "HTParseInet: NSL_FORK child %d dumped core!\n",
+ (int)waitret);
}
-#endif
+#endif /* WCOREDUMP */
} else if (WIFSTOPPED(cst1)) {
fprintf(stderr,
- "NSL_FORK: Child %d is stopped, status 0x%x!\n",
+ "HTParseInet: NSL_FORK child %d is stopped, status 0x%x!\n",
(int)waitret, cst1);
}
}
@@ -503,22 +518,28 @@ PUBLIC int HTParseInet ARGS2(
*/
IOCTL(pfd[0], FIONREAD, &cstat);
if (cstat < 4) {
- if (TRACE)
+ if (TRACE) {
fprintf(stderr,
- "NSL_FORK: Child returns only %d bytes, \
-trying again without forking...\n", cstat);
+ "HTParseInet: NSL_FORK child returns only %d bytes.\n",
+ cstat);
+ fprintf(stderr,
+ " Trying again without forking.\n");
+ }
phost = gethostbyname(host); /* See netdb.h */
if (!phost) {
- if (TRACE)
+ if (TRACE) {
fprintf(stderr,
- "HTParseInet: Can't find internet node name `%s'.\n",host);
+ "HTParseInet: Can't find internet node name `%s'.\n",
+ host);
+ }
memset((void *)&sin->sin_addr, 0, sizeof(sin->sin_addr));
} else {
- memcpy((void *)&sin->sin_addr, phost->h_addr, phost->h_length);
+ memcpy((void *)&sin->sin_addr,
+ phost->h_addr, phost->h_length);
}
-#if 0
+#ifdef NOTDEFINED
cstat = read(pfd[0], (void *)&sin->sin_addr , 4);
-#endif
+#endif /* NOTDEFINED */
} else {
cstat = read(pfd[0], (void *)&sin->sin_addr , cstat);
}
@@ -526,16 +547,20 @@ trying again without forking...\n", cstat);
close(pfd[1]);
}
if (sin->sin_addr.s_addr == 0) {
- if (TRACE)
+ if (TRACE) {
fprintf(stderr,
- "HTTPAccess: Can't find internet node name `%s'.\n",host);
- FREE(host);
- return -1;
+ "HTParseInet: Can't find internet node name `%s'.\n",
+ host);
+ }
+ FREE(host);
+ return -1;
}
FREE(host);
#ifdef MVS
- if (TRACE)
- fprintf(stderr, "HTTCP: gethostbyname() returned %d\n", phost);
+ if (TRACE) {
+ fprintf(stderr,
+ "HTParseInet: gethostbyname() returned %d\n", phost);
+ }
#endif /* MVS */
#else /* Not NSL_FORK: */
@@ -551,13 +576,17 @@ trying again without forking...\n", cstat);
#else
phost = gethostbyname(host); /* See netdb.h */
#ifdef MVS
- if (TRACE)
- fprintf(stderr, "HTTCP: gethostbyname() returned %d\n", phost);
+ if (TRACE) {
+ fprintf(stderr,
+ "HTParseInet: gethostbyname() returned %d\n", phost);
+ }
#endif /* MVS */
if (!phost) {
- if (TRACE)
+ if (TRACE) {
fprintf(stderr,
- "HTTPAccess: Can't find internet node name `%s'.\n",host);
+ "HTParseInet: Can't find internet node name `%s'.\n",
+ host);
+ }
FREE(host);
return -1; /* Fail? */
}
@@ -579,15 +608,15 @@ trying again without forking...\n", cstat);
#endif /* NSL_FORK */
}
- if (TRACE)
+ if (TRACE) {
fprintf(stderr,
- "TCP: Parsed address as port %d, IP address %d.%d.%d.%d\n",
+ "HTParseInet: Parsed address as port %d, IP address %d.%d.%d.%d\n",
(int)ntohs(sin->sin_port),
(int)*((unsigned char *)(&sin->sin_addr)+0),
(int)*((unsigned char *)(&sin->sin_addr)+1),
(int)*((unsigned char *)(&sin->sin_addr)+2),
(int)*((unsigned char *)(&sin->sin_addr)+3));
-
+ }
#endif /* Internet vs. Decnet */
return 0; /* OK */
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index 0bcc2c62..f56f2daa 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -261,7 +261,8 @@ try_again:
if (pres->rep_out == WWW_PRESENT) {
if (pres->rep != WWW_SOURCE &&
strcasecomp(HTAtom_name(pres->rep), "www/mime") &&
- strcasecomp(HTAtom_name(pres->rep), "www/compressed")) {
+ strcasecomp(HTAtom_name(pres->rep), "www/compressed") &&
+ pres->quality <= 1.0 && pres->quality >= 0.0) {
if (pres->quality < 1.0) {
if (pres->maxbytes > 0) {
sprintf(temp, ";q=%4.3f;mxb=%ld",
@@ -459,7 +460,7 @@ try_again:
} else {
if (TRACE)
fprintf(stderr,
- "HTTP: Not sending authorization (yet)\n");
+ "HTTP: Not sending authorization (yet).\n");
}
/*
** Add 'Cookie:' header, if it's HTTP or HTTPS
@@ -802,14 +803,16 @@ try_again:
error_file = fopen(http_error_file, "w");
if (error_file) { /* Managed to open the file */
fprintf(error_file, "error=%d\n", server_status);
+ fclose(error_file);
+ }
#else
error_file = fopen(http_error_file, "a");
if (error_file) { /* Managed to open the file */
fprintf(error_file, " URL=%s (%s)\n", url, METHOD);
fprintf(error_file, "STATUS=%s\n", line_buffer);
-#endif /* SERVER_STATUS_ONLY */
fclose(error_file);
}
+#endif /* SERVER_STATUS_ONLY */
}
/*
@@ -944,11 +947,13 @@ try_again:
** Various forms of Redirection. - FM
** 300 Multiple Choices.
** 301 Moved Permanently.
- ** 302 Moved Temporarily.
- ** 303 See Other.
+ ** 302 General (temporary) Redirection (we can, and do, use GET).
+ ** 303 See Other (always use GET).
** 304 Not Modified.
** 305 Use Proxy.
- ** > 305 is unknown.
+ ** 306 Set Proxy.
+ ** 307 Temporary Redirect with method retained.
+ ** > 308 is unknown.
*/
if (no_url_redirection || do_head || keep_mime_headers) {
/*
@@ -973,6 +978,20 @@ try_again:
* choices (i.e., we use the latter, for now). - FM
*/
HTAlert(line_buffer);
+ if (traversal) {
+ HTTP_NETCLOSE(s, handle);
+ status = -1;
+ goto clean_up;
+ }
+ if (!dump_output_immediately &&
+ format_out == HTAtom_for("www/download")) {
+ /*
+ * Convert a download request to
+ * a presentation request for
+ * interactive users. - FM
+ */
+ format_out = WWW_PRESENT;
+ }
break;
}
@@ -992,18 +1011,36 @@ try_again:
/*
* We don't want to compound proxying, so if we
* got this from a proxy, just show any message
- * to the user. - FM
+ * to the user. Otherwise, we look for a Location:
+ * header and use that if present. We should also
+ * look for a Set-Proxy: header, but that's not yet
+ * implemented. - FM
*/
if (using_proxy) {
HTAlert("Got redirection to a proxy from the proxy!");
break;
}
- } else if (server_status > 305) {
+ } else if (server_status == 306 || server_status > 307) {
/*
- * Show user the content, if any, for redirection
- * statuses we don't know. - FM
+ * Show user the content, if any, for 306 until we
+ * implement Set-Proxy: header handling, and for
+ * redirection statuses we don't know. - FM
*/
HTAlert(line_buffer);
+ if (traversal) {
+ HTTP_NETCLOSE(s, handle);
+ status = -1;
+ goto clean_up;
+ }
+ if (!dump_output_immediately &&
+ format_out == HTAtom_for("www/download")) {
+ /*
+ * Convert a download request to
+ * a presentation request for
+ * interactive users. - FM
+ */
+ format_out = WWW_PRESENT;
+ }
break;
}
@@ -1015,14 +1052,15 @@ try_again:
* If that's another redirecting_url, we'll repeat the
* checks, and fetch initiations if acceptible, until
* we reach the actual URL, or the redirection limit
- * set in HTAccess.c is exceeded. If the status was 301,
+ * set in HTAccess.c is exceeded. If the status was 301
* indicating that the relocation is permanent, we set
* the permanent_redirection flag to make it permanent
* for the current anchor tree (i.e., will persist until
* the tree is freed or the client exits). If the
* redirection would include POST content, we seek
- * confirmation from an interactive user, and otherwise
- * refuse the redirection. We also don't allow permanent
+ * confirmation from an interactive user, with option to
+ * use 303 for 301 (but not for 307), and otherwise refuse
+ * the redirection. We also don't allow permanent
* redirection if we keep POST content. If we don't find
* the Location header or it's value is zero-length, we
* display whatever the server returned, and the user
@@ -1034,7 +1072,10 @@ try_again:
char *cp;
if ((dump_output_immediately || traversal) &&
- do_post && server_status != 303) {
+ do_post &&
+ server_status != 303 &&
+ server_status != 302 &&
+ server_status != 301) {
/*
* Don't redirect POST content without approval
* from an interactive user. - FM
@@ -1079,7 +1120,7 @@ try_again:
*/
if (TRACE)
fprintf(stderr,
- "HTTP: Have POST content. Treating 301 (Permanent) as 302 (Temporary).\n");
+ "HTTP: Have POST content. Treating 301 (Permanent) as Temporary.\n");
HTAlert(
"Have POST content. Treating Permanent Redirection as Temporary.\n");
} else {
@@ -1347,12 +1388,14 @@ Cookie2_continuation:
"HTTP: Proxy URL is '%s'\n",
redirecting_url);
}
- if (!do_post || server_status == 303) {
+ if (!do_post ||
+ server_status == 303 ||
+ server_status == 302) {
/*
* We don't have POST content (nor support PUT
- * or DELETE), or the status is "See Other" and
- * we can convert to GET, so go back and check
- * out the new URL. - FM
+ * or DELETE), or the status is "See Other" or
+ * "General Redirection" and we can convert to
+ * GET, so go back and check out the new URL. - FM
*/
status = HT_REDIRECTING;
goto clean_up;
@@ -1361,7 +1404,8 @@ Cookie2_continuation:
* Make sure the user wants to redirect
* the POST content, or treat as GET - FM & DK
*/
- switch (HTConfirmPostRedirect(redirecting_url)) {
+ switch (HTConfirmPostRedirect(redirecting_url,
+ server_status)) {
/*
* User failed to confirm.
* Abort the fetch.
@@ -1413,6 +1457,20 @@ Cookie2_continuation:
length = strlen(start_of_data);
HTAlert("Got redirection with no Location header.");
HTProgress(line_buffer);
+ if (traversal) {
+ HTTP_NETCLOSE(s, handle);
+ status = -1;
+ goto clean_up;
+ }
+ if (!dump_output_immediately &&
+ format_out == HTAtom_for("www/download")) {
+ /*
+ * Convert a download request to
+ * a presentation request for
+ * interactive users. - FM
+ */
+ format_out = WWW_PRESENT;
+ }
break;
}
@@ -1513,6 +1571,15 @@ Cookie2_continuation:
break;
} else if (!(traversal || dump_output_immediately) &&
HTConfirm("Show the 407 message body?")) {
+ if (!dump_output_immediately &&
+ format_out == HTAtom_for("www/download")) {
+ /*
+ * Convert a download request to
+ * a presentation request for
+ * interactive users. - FM
+ */
+ format_out = WWW_PRESENT;
+ }
break;
} else {
if (traversal || dump_output_immediately)
@@ -1562,6 +1629,15 @@ Cookie2_continuation:
status = -1;
goto clean_up;
}
+ if (!dump_output_immediately &&
+ format_out == HTAtom_for("www/download")) {
+ /*
+ * Convert a download request to
+ * a presentation request for
+ * interactive users. - FM
+ */
+ format_out = WWW_PRESENT;
+ }
break;
} /* case 4 switch */
break;
@@ -1580,6 +1656,20 @@ Cookie2_continuation:
** we always should display. - FM
*/
HTAlert(line_buffer);
+ if (traversal) {
+ HTTP_NETCLOSE(s, handle);
+ status = -1;
+ goto clean_up;
+ }
+ if (!dump_output_immediately &&
+ format_out == HTAtom_for("www/download")) {
+ /*
+ * Convert a download request to
+ * a presentation request for
+ * interactive users. - FM
+ */
+ format_out = WWW_PRESENT;
+ }
break;
default:
@@ -1595,6 +1685,15 @@ Cookie2_continuation:
status = -1;
goto clean_up;
}
+ if (!dump_output_immediately &&
+ format_out == HTAtom_for("www/download")) {
+ /*
+ * Convert a download request to
+ * a presentation request for
+ * interactive users. - FM
+ */
+ format_out = WWW_PRESENT;
+ }
break;
} /* Switch on server_status/100 */
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index ec013fc5..a0c93655 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -364,6 +364,8 @@ Sucess (>=0) and failure (<0) codes
#define HT_NOT_LOADED -29999
#define HT_OK 0 /* Generic success*/
+#define HT_ERROR -1 /* Generic failure */
+
#define HT_NO_ACCESS -10 /* Access not available */
#define HT_FORBIDDEN -11 /* Access forbidden */
#define HT_INTERNAL -12 /* Weird -- should never happen. */
diff --git a/WWW/Library/djgpp/makefile b/WWW/Library/djgpp/makefile
index d3cc446e..cf37f9f1 100644
--- a/WWW/Library/djgpp/makefile
+++ b/WWW/Library/djgpp/makefile
@@ -7,7 +7,7 @@ WWW_MACH = djgpp
# The ASIS repository's name for the machine we are on
#ASIS_MACH = hardware/os
-CFLAGS = -O -DCOLOR_CURSES -DDOSPATH -DNOUSERS -DDEBUG -I../../../djgpp/tcplib/include -I../../../djgpp/tcplib/include/tcp
+CFLAGS = -O3 -DEXP_CHARTRANS -DCOLOR_CURSES -DDOSPATH -DNOUSERS -DDEBUG -I../../../djgpp/tcplib/include -I../../../djgpp/tcplib/include/tcp
LFLAGS =
CC = gcc
diff --git a/lynx.cfg b/lynx.cfg
index 495208dc..61c1226c 100644
--- a/lynx.cfg
+++ b/lynx.cfg
@@ -222,6 +222,7 @@ DEFAULT_INDEX_FILE:http://www.ncsa.uiuc.edu/SDG/Software/Mosaic/MetaIndex.html
# ISO Latin 9 (Latin 5) iso-8859-9
# ISO Latin 10 iso-8859-10
# PC Latin2 CP 852 cp852
+# DOSCyrillic (cp866) cp866
# MS Windows CP 1250 windows-1250
# WinCyrillic (cp1251) windows-1251
# MS Windows CP 1252 iso-8859-1-windows-3.1-latin-1
diff --git a/makefile.in b/makefile.in
index 285e4bff..5260447a 100644
--- a/makefile.in
+++ b/makefile.in
@@ -124,6 +124,7 @@ SITE_DEFS = # Your defines here
# -DUSEHASH (see README.configure)
# -DUSE_COLOR_STYLE (see README.configure)
# -DUSE_SLANG (see README.configure)
+# -DUSE_ZLIB To use some functions from zlib library if you have it.
#
# if you are linking to freeWAIS-0.202 or older, you should define this
# in MCFLAGS (SITE_DEFS)
diff --git a/samples/lynx.cfg b/samples/lynx.cfg
index d760fb93..e61360a1 100644
--- a/samples/lynx.cfg
+++ b/samples/lynx.cfg
@@ -222,7 +222,9 @@ DEFAULT_INDEX_FILE:http://www.ncsa.uiuc.edu/SDG/Software/Mosaic/MetaIndex.html
# ISO Latin 9 (Latin 5) iso-8859-9
# ISO Latin 10 iso-8859-10
# PC Latin2 CP 852 cp852
+# DOSCyrillic (cp866) cp866
# MS Windows CP 1250 windows-1250
+# WinCyrillic (cp1251) windows-1251
# MS Windows CP 1252 iso-8859-1-windows-3.1-latin-1
# UNICODE UTF 8 unicode-1-1-utf-8
# RFC 1345 w/o Intro mnemonic+ascii+0
diff --git a/samples/mailcap b/samples/mailcap
index 9197331c..9dd36ccf 100644
--- a/samples/mailcap
+++ b/samples/mailcap
@@ -30,7 +30,7 @@
# for the existance of a DISPLAY environment variable.
# Lynx actually uses a getenv() call for DISPLAY (DECW$DISPLAY
# on VMS) when it encounters test=test -n "$DISPLAY" or
-# test=test -z "$DISPAY" in a viewer assignment, instead of
+# test=test -z "$DISPLAY" in a viewer assignment, instead of
# spawning to execute "test" via a system() call, i.e., those
# two strings, respectively, are handled equivalently to the
# :XWINDOWS and :NON_XWINDOWS flags for VIEWER: assignments
diff --git a/src/DefaultStyle.c b/src/DefaultStyle.c
index 974a27db..140f0a77 100644
--- a/src/DefaultStyle.c
+++ b/src/DefaultStyle.c
@@ -38,324 +38,324 @@ PRIVATE HTTabStop tabs_16[] = {
PRIVATE HTStyle HTStyleNormal = {
0, "Normal", "P",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
3, 3, 6, HT_LEFT, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleDivCenter = {
&HTStyleNormal, "DivCenter", "DCENTER",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
3, 3, 6, HT_CENTER, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleDivLeft = {
&HTStyleDivCenter, "DivLeft", "DLEFT",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
3, 3, 6, HT_LEFT, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleDivRight = {
&HTStyleDivLeft, "DivRight", "DRIGHT",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
3, 3, 6, HT_RIGHT, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleBanner = {
&HTStyleDivRight, "Banner", "BANNER",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
3, 3, 6, HT_LEFT, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleBlockquote = {
&HTStyleBanner, "Blockquote", "BLOCKQUOTE",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
5, 5, 7, HT_LEFT, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleBq = { /* HTML 3.0 BLOCKQUOTE - FM */
&HTStyleBlockquote, "Bq", "BQ",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
5, 5, 7, HT_LEFT, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleFootnote = { /* HTML 3.0 FN - FM */
&HTStyleBq, "Footnote", "FN",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
5, 5, 7, HT_LEFT, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleList = {
&HTStyleFootnote, "List", "UL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
3, 7, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0 };
PRIVATE HTStyle HTStyleList1 = {
&HTStyleList, "List1", "UL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
8, 12, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0 };
PRIVATE HTStyle HTStyleList2 = {
&HTStyleList1, "List2", "UL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
13, 17, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0 };
PRIVATE HTStyle HTStyleList3 = {
&HTStyleList2, "List3", "UL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
18, 22, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0 };
PRIVATE HTStyle HTStyleList4 = {
&HTStyleList3, "List4", "UL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
23, 27, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0 };
PRIVATE HTStyle HTStyleList5 = {
&HTStyleList4, "List5", "UL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
28, 32, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0 };
PRIVATE HTStyle HTStyleList6 = {
&HTStyleList5, "List6", "UL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
33, 37, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0 };
PRIVATE HTStyle HTStyleMenu = {
&HTStyleList6, "Menu", "MENU",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
3, 7, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleMenu1 = {
&HTStyleMenu, "Menu1", "MENU",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
8, 12, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleMenu2= {
&HTStyleMenu1, "Menu2", "MENU",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
13, 17, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleMenu3= {
&HTStyleMenu2, "Menu3", "MENU",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
18, 22, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleMenu4= {
&HTStyleMenu3, "Menu4", "MENU",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
23, 27, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleMenu5= {
&HTStyleMenu4, "Menu5", "MENU",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
28, 33, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleMenu6= {
&HTStyleMenu5, "Menu6", "MENU",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
33, 38, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleGlossary = {
&HTStyleMenu6, "Glossary", "DL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
3, 10, 6, HT_LEFT, 1, 0, 0,
YES, YES, 1, 1, 0
};
PRIVATE HTStyle HTStyleGlossary1 = {
&HTStyleGlossary, "Glossary1", "DL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
8, 16, 6, HT_LEFT, 1, 0, 0,
YES, YES, 1, 1, 0
};
PRIVATE HTStyle HTStyleGlossary2 = {
&HTStyleGlossary1, "Glossary2", "DL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
14, 22, 6, HT_LEFT, 1, 0, 0,
YES, YES, 1, 1, 0
};
PRIVATE HTStyle HTStyleGlossary3 = {
&HTStyleGlossary2, "Glossary3", "DL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
20, 28, 6, HT_LEFT, 1, 0, 0,
YES, YES, 1, 1, 0
};
PRIVATE HTStyle HTStyleGlossary4 = {
&HTStyleGlossary3, "Glossary4", "DL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
26, 34, 6, HT_LEFT, 1, 0, 0,
YES, YES, 1, 1, 0
};
PRIVATE HTStyle HTStyleGlossary5 = {
&HTStyleGlossary4, "Glossary5", "DL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
32, 40, 6, HT_LEFT, 1, 0, 0,
YES, YES, 1, 1, 0
};
PRIVATE HTStyle HTStyleGlossary6 = {
&HTStyleGlossary5, "Glossary6", "DL",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
38, 46, 6, HT_LEFT, 1, 0, 0,
YES, YES, 1, 1, 0
};
PRIVATE HTStyle HTStyleGlossaryCompact = {
&HTStyleGlossary6, "GlossaryCompact", "DLC",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
3, 10, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleGlossaryCompact1 = {
&HTStyleGlossaryCompact, "GlossaryCompact1", "DLC",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
8, 15, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleGlossaryCompact2 = {
&HTStyleGlossaryCompact1, "GlossaryCompact2", "DLC",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
13, 20, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleGlossaryCompact3 = {
&HTStyleGlossaryCompact2, "GlossaryCompact3", "DLC",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
18, 25, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleGlossaryCompact4 = {
&HTStyleGlossaryCompact3, "GlossaryCompact4", "DLC",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
23, 30, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleGlossaryCompact5 = {
&HTStyleGlossaryCompact4, "GlossaryCompact5", "DLC",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
28, 35, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleGlossaryCompact6 = {
&HTStyleGlossaryCompact5, "GlossaryCompact6", "DLC",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
33, 40, 6, HT_LEFT, 1, 0, 0,
YES, YES, 0, 0, 0
};
PRIVATE HTStyle HTStyleExample = {
&HTStyleGlossaryCompact6, "Example", "XMP",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
0, 0, 0, HT_LEFT, 1, 0, tabs_8,
NO, NO, 0, 0, 0
};
PRIVATE HTStyle HTStylePreformatted = {
&HTStyleExample, "Preformatted", "PRE",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
0, 0, 0, HT_LEFT, 1, 0, tabs_8,
NO, NO, 0, 0, 0
};
PRIVATE HTStyle HTStyleListing = {
&HTStylePreformatted, "Listing", "LISTING",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
0, 0, 0, HT_LEFT, 1, 0, tabs_8,
NO, NO, 0, 0, 0 };
PRIVATE HTStyle HTStyleAddress = {
&HTStyleListing, "Address", "ADDRESS",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
4, 4, 7, HT_LEFT, 1, 0, tabs_8,
YES, YES, 2, 0, 0 };
PRIVATE HTStyle HTStyleNote = { /* HTML 3.0 NOTE - FM */
&HTStyleAddress, "Note", "NOTE",
- HT_FONT, 1.0, HT_BLACK, 0, 0,
+ HT_FONT, 1, HT_BLACK, 0, 0,
5, 5, 7, HT_LEFT, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleHeading1 = {
&HTStyleNote, "Heading1", "H1",
- HT_FONT+HT_BOLD, 1.0, HT_BLACK, 0, 0,
+ HT_FONT+HT_BOLD, 1, HT_BLACK, 0, 0,
0, 0, 0, HT_CENTER, 1, 0, 0,
YES, YES, 1, 1, 0 };
PRIVATE HTStyle HTStyleHeading2 = {
&HTStyleHeading1, "Heading2", "H2",
- HT_FONT+HT_BOLD, 1.0, HT_BLACK, 0, 0,
+ HT_FONT+HT_BOLD, 1, HT_BLACK, 0, 0,
0, 0, 0, HT_LEFT, 1, 0, 0,
YES, YES, 1, 1, 0 };
PRIVATE HTStyle HTStyleHeading3 = {
&HTStyleHeading2, "Heading3", "H3",
- HT_FONT+HT_BOLD, 1.0, HT_BLACK, 0, 0,
+ HT_FONT+HT_BOLD, 1, HT_BLACK, 0, 0,
2, 2, 0, HT_LEFT, 1, 0, 0,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleHeading4 = {
&HTStyleHeading3, "Heading4", "H4",
- HT_FONT+HT_BOLD, 1.0, HT_BLACK, 0, 0,
+ HT_FONT+HT_BOLD, 1, HT_BLACK, 0, 0,
4, 4, 0, HT_LEFT, 1, 0, 0,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleHeading5 = {
&HTStyleHeading4, "Heading5", "H5",
- HT_FONT+HT_BOLD, 1.0, HT_BLACK, 0, 0,
+ HT_FONT+HT_BOLD, 1, HT_BLACK, 0, 0,
6, 6, 0, HT_LEFT, 1, 0, 0,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleHeading6 = {
&HTStyleHeading5, "Heading6", "H6",
- HT_FONT+HT_BOLD, 1.0, HT_BLACK, 0, 0,
+ HT_FONT+HT_BOLD, 1, HT_BLACK, 0, 0,
8, 8, 0, HT_LEFT, 1, 0, 0,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleHeadingCenter = {
&HTStyleHeading6, "HeadingCenter", "HCENTER",
- HT_FONT+HT_BOLD, 1.0, HT_BLACK, 0, 0,
+ HT_FONT+HT_BOLD, 1, HT_BLACK, 0, 0,
0, 0, 3, HT_CENTER, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleHeadingLeft = {
&HTStyleHeadingCenter, "HeadingLeft", "HLEFT",
- HT_FONT+HT_BOLD, 1.0, HT_BLACK, 0, 0,
+ HT_FONT+HT_BOLD, 1, HT_BLACK, 0, 0,
0, 0, 3, HT_LEFT, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
PRIVATE HTStyle HTStyleHeadingRight = {
&HTStyleHeadingLeft, "HeadingRight", "HRIGHT",
- HT_FONT+HT_BOLD, 1.0, HT_BLACK, 0, 0,
+ HT_FONT+HT_BOLD, 1, HT_BLACK, 0, 0,
0, 0, 3, HT_RIGHT, 1, 0, tabs_8,
YES, YES, 1, 0, 0 };
diff --git a/src/GridText.c b/src/GridText.c
index 0f764f49..e1c414d6 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -230,7 +230,7 @@ PRIVATE int ctrl_chars_on_this_line = 0; /* num of ctrl chars in current line */
PRIVATE HTStyle default_style =
{ 0, "(Unstyled)", "",
- (HTFont)0, 1.0, HT_BLACK, 0, 0,
+ (HTFont)0, 1, HT_BLACK, 0, 0,
0, 0, 0, HT_LEFT, 1, 0, 0,
NO, NO, 0, 0, 0 };
@@ -1834,10 +1834,18 @@ PRIVATE void split_line ARGS2(
*/
if (split > 0) {
for (a = text->first_anchor; a; a = a->next) {
- if (a->line_num == CurLine && a->line_pos >= split) {
- a->start += (1 + SpecialAttrChars - HeadTrim - TailTrim);
- a->line_pos -= (split - SpecialAttrChars + HeadTrim);
- a->line_num = text->Lines;
+ if (a->line_num == CurLine) {
+ if (a->line_pos >= split) {
+ a->start += (1 + SpecialAttrChars - HeadTrim - TailTrim);
+ a->line_pos -= (split - SpecialAttrChars + HeadTrim);
+ a->line_num = text->Lines;
+ } else if ((a->link_type & HYPERTEXT_ANCHOR) &&
+ (a->line_pos + a->extent) >= split) {
+ a->extent -= (TailTrim + HeadTrim);
+ if (a->extent < 0) {
+ a->extent = 0;
+ }
+ }
}
}
}
@@ -2431,8 +2439,8 @@ PUBLIC int HText_beginAnchor ARGS3(
if (a == NULL)
outofmem(__FILE__, "HText_beginAnchor");
- a->hightext = 0;
- a->hightext2 = 0;
+ a->hightext = NULL;
+ a->hightext2 = NULL;
a->start = text->chars + text->last_line->size;
a->inUnderline = underline;
@@ -2946,7 +2954,7 @@ PRIVATE void remove_special_attr_chars ARGS1(
PUBLIC void HText_endAppend ARGS1(
HText *, text)
{
- int cur_line, cur_char, cur_shift;
+ int cur_line, cur_char, cur_shift, len;
TextAnchor *anchor_ptr;
HTLine *line_ptr;
unsigned char ch;
@@ -3084,16 +3092,41 @@ re_parse:
* Double check that we have a line pointer,
* and if so, copy into hightext2.
*/
- if (line_ptr) {
+ if (line_ptr2) {
StrnAllocCopy(anchor_ptr->hightext2,
line_ptr2->data,
(anchor_ptr->extent -
strlen(anchor_ptr->hightext)));
anchor_ptr->hightext2offset = line_ptr2->offset;
remove_special_attr_chars(anchor_ptr->hightext2);
+ if (anchor_ptr->link_type & HYPERTEXT_ANCHOR) {
+ if ((len = strlen(anchor_ptr->hightext2)) > 0) {
+ len--;
+ while (len >= 0 &&
+ isspace((unsigned char)
+ anchor_ptr->hightext2[len])) {
+ anchor_ptr->hightext2[len] = '\0';
+ len--;
+ }
+ }
+ if (len <= 0 && anchor_ptr->hightext2[0] == '\0') {
+ FREE(anchor_ptr->hightext2);
+ anchor_ptr->hightext2offset = 0;
+ }
+ }
}
- }
+ }
remove_special_attr_chars(anchor_ptr->hightext);
+ if (anchor_ptr->link_type & HYPERTEXT_ANCHOR) {
+ if ((len = strlen(anchor_ptr->hightext)) > 0) {
+ len--;
+ while (len >= 0 &&
+ isspace((unsigned char)anchor_ptr->hightext[len])) {
+ anchor_ptr->hightext[len] = '\0';
+ len--;
+ }
+ }
+ }
/*
* Subtract any formatting characters from the x position
@@ -3511,7 +3544,7 @@ PUBLIC BOOL HText_getFirstTargetInLine ARGS7(
*/
PUBLIC int HText_getNumOfLines NOARGS
{
- return(HTMainText ? HTMainText->Lines : 0);
+ return(HTMainText ? HTMainText->Lines : 0);
}
/*
@@ -3520,7 +3553,7 @@ PUBLIC int HText_getNumOfLines NOARGS
*/
PUBLIC char * HText_getTitle NOARGS
{
- return(HTMainText ?
+ return(HTMainText ?
(char *) HTAnchor_title(HTMainText->node_anchor) : NULL);
}
@@ -3535,21 +3568,212 @@ PUBLIC char *HText_getStyle NOARGS
/*
* HText_getSugFname returns the suggested filename of the current
* document (normally derived from a Content-Disposition header with
- * file; filename=name.suffix). - FM
+ * attachment; filename=name.suffix). - FM
*/
PUBLIC char * HText_getSugFname NOARGS
{
- return(HTMainText ?
+ return(HTMainText ?
(char *) HTAnchor_SugFname(HTMainText->node_anchor) : NULL);
}
/*
+ * HTCheckFnameForCompression receives the address of an allocated
+ * string containing a filename, and an anchor pointer, and expands
+ * or truncates the string's suffix if appropriate, based on whether
+ * the anchor indicates that the file is compressed. We assume
+ * that the file was not uncompressed (as when downloading), and
+ * believe the headers about whether it's compressed or not. - FM
+ *
+ * Added third arg - if strip_ok is FALSE, we don't trust the anchor
+ * info enough to remove a compression suffix if the anchor object
+ * does not indicate compression. - kw
+ */
+PUBLIC void HTCheckFnameForCompression ARGS3(
+ char **, fname,
+ HTParentAnchor *, anchor,
+ BOOL, strip_ok)
+{
+ char *fn = *fname;
+ char *dot = NULL, *cp = NULL;
+ CONST char *ct = NULL;
+ CONST char *ce = NULL;
+ BOOLEAN method = 0;
+
+ /*
+ * Make sure we have a string and anchor. - FM
+ */
+ if (!(fn && *fn && anchor))
+ return;
+
+ /*
+ * Make sure we have a file, not directory, name. -FM
+ */
+ if ((cp = strrchr(fn, '/')) != NULL) {
+ fn = (cp +1);
+ if (*fn == '\0') {
+ return;
+ }
+ }
+
+ /*
+ * Check the anchor's content_type and content_encoding
+ * elements for a gzip or Unix compressed file. - FM
+ */
+ ct = HTAnchor_content_type(anchor);
+ ce = HTAnchor_content_encoding(anchor);
+ if (ce == NULL) {
+ /*
+ * No Content-Encoding, so check
+ * the Content-Type. - FM
+ */
+ if (!strncasecomp((ct ? ct : ""), "application/gzip", 16) ||
+ !strncasecomp((ct ? ct : ""), "application/x-gzip", 18)) {
+ method = 1;
+ } else if (!strncasecomp((ct ? ct : ""),
+ "application/compress", 20) ||
+ !strncasecomp((ct ? ct : ""),
+ "application/x-compress", 22)) {
+ method = 2;
+ }
+ } else if (!strcasecomp(ce, "gzip") ||
+ !strcasecomp(ce, "x-gzip")) {
+ /*
+ * It's gzipped. - FM
+ */
+ method = 1;
+ } else if (!strcasecomp(ce, "compress") ||
+ !strcasecomp(ce, "x-compress")) {
+ /*
+ * It's Unix compressed. - FM
+ */
+ method = 2;
+ }
+
+ /*
+ * If no Content-Encoding has been detected via the anchor
+ * pointer, but strip_ok is not set, there is nothing left
+ * to do. - kw
+ */
+ if (method == 0 && !strip_ok)
+ return;
+
+ /*
+ * Seek the last dot, and check whether
+ * we have a gzip or compress suffix. - FM
+ */
+ if ((dot = strrchr(fn, '.')) != NULL) {
+ if (!strcasecomp(dot, ".tgz") ||
+ !strcasecomp(dot, ".gz") ||
+ !strcasecomp(dot, ".Z")) {
+ if (!method) {
+ /*
+ * It has a suffix which signifies a gzipped
+ * or compressed file for us, but the anchor
+ * claims otherwise, so tweak the suffix. - FM
+ */
+ cp = (dot + 1);
+ *dot = '\0';
+ if (!strcasecomp(cp, "tgz")) {
+ StrAllocCat(*fname, ".tar");
+ }
+ }
+ return;
+ }
+ if (strlen(dot) > 4) {
+ cp = ((dot + strlen(dot)) - 3);
+ if (!strcasecomp(cp, "-gz") ||
+ !strcasecomp(cp, "_gz")) {
+ if (!method) {
+ /*
+ * It has a tail which signifies a gzipped
+ * file for us, but the anchor claims otherwise,
+ * so tweak the suffix. - FM
+ */
+ *dot = '\0';
+ } else {
+ /*
+ * The anchor claims it's gzipped, and we
+ * believe it, so force this tail to the
+ * conventional suffix. - FM
+ */
+#ifdef VMS
+ *cp = '-';
+#else
+ *cp = '.';
+#endif /* VMS */
+ cp++;
+ *cp = TOLOWER(*cp);
+ cp++;
+ *cp = TOLOWER(*cp);
+ }
+ return;
+ }
+ }
+ if (strlen(dot) > 3) {
+ cp = ((dot + strlen(dot)) - 2);
+ if (!strcasecomp(cp, "-Z") ||
+ !strcasecomp(cp, "_Z")) {
+ if (!method) {
+ /*
+ * It has a tail which signifies a compressed
+ * file for us, but the anchor claims otherwise,
+ * so tweak the suffix. - FM
+ */
+ *dot = '\0';
+ } else {
+ /*
+ * The anchor claims it's compressed, and
+ * we believe it, so force this tail to the
+ * conventional suffix. - FM
+ */
+#ifdef VMS
+ *cp = '-';
+#else
+ *cp = '.';
+#endif /* VMS */
+ cp++;
+ *cp = TOUPPER(*cp);
+ }
+ return;
+ }
+ }
+ }
+ if (!method) {
+ /*
+ * Don't know what compression method
+ * was used, if any, so we won't do
+ * anything. - FM
+ */
+ return;
+ }
+
+ /*
+ * Add the appropriate suffix. - FM
+ */
+ if (!dot) {
+ StrAllocCat(*fname, ((method == 1) ? ".gz" : ".Z"));
+ return;
+ }
+ dot++;
+ if (*dot == '\0') {
+ StrAllocCat(*fname, ((method == 1) ? "gz" : "Z"));
+ return;
+ }
+#ifdef VMS
+ StrAllocCat(*fname, ((method == 1) ? "-gz" : "-Z"));
+#else
+ StrAllocCat(*fname, ((method == 1) ? ".gz" : ".Z"));
+#endif /* !VMS */
+ return;
+}
+
+/*
* HText_getLastModified returns the Last-Modified header
* if available, for the current document. - FM
*/
PUBLIC char * HText_getLastModified NOARGS
{
- return(HTMainText ?
+ return(HTMainText ?
(char *) HTAnchor_last_modified(HTMainText->node_anchor) : NULL);
}
@@ -3559,7 +3783,7 @@ PUBLIC char * HText_getLastModified NOARGS
*/
PUBLIC char * HText_getDate NOARGS
{
- return(HTMainText ?
+ return(HTMainText ?
(char *) HTAnchor_date(HTMainText->node_anchor) : NULL);
}
@@ -3569,7 +3793,7 @@ PUBLIC char * HText_getDate NOARGS
*/
PUBLIC char * HText_getServer NOARGS
{
- return(HTMainText ?
+ return(HTMainText ?
(char *)HTAnchor_server(HTMainText->node_anchor) : NULL);
}
@@ -4258,10 +4482,22 @@ PUBLIC void print_wwwfile_to_fd ARGS2(
fputc(' ',fp);
/* add data */
- for (i = 0; line->data[i] != '\0'; i++)
- if (!IsSpecialAttrChar(line->data[i]))
+ for (i = 0; line->data[i] != '\0'; i++) {
+ if (!IsSpecialAttrChar(line->data[i])) {
fputc(line->data[i],fp);
- else if (dump_output_immediately && use_underscore) {
+ } else if (line->data[i] == LY_SOFT_HYPHEN &&
+ line->data[i + 1] == '\0') { /* last char on line */
+ if (dump_output_immediately &&
+ LYRawMode &&
+ LYlowest_eightbit[current_char_set] <= 173 &&
+ (current_char_set == 0 ||
+ LYCharSet_UC[current_char_set].enc == UCT_ENC_8859 ||
+ LYCharSet_UC[current_char_set].like8859 & UCT_R_8859SPECL)) {
+ fputc(0xad, fp); /* the iso8859 byte for SHY */
+ } else {
+ fputc('-', fp);
+ }
+ } else if (dump_output_immediately && use_underscore) {
switch (line->data[i]) {
case LY_UNDERLINE_START_CHAR:
case LY_UNDERLINE_END_CHAR:
@@ -4271,7 +4507,9 @@ PUBLIC void print_wwwfile_to_fd ARGS2(
case LY_BOLD_END_CHAR:
break;
}
- }
+ }
+ }
+
/* add the return */
fputc('\n',fp);
@@ -4320,10 +4558,23 @@ PUBLIC void print_crawl_to_fd ARGS3(
/*
* Add data.
*/
- for (i = 0; line->data[i] != '\0'; i++)
- if (!IsSpecialAttrChar(line->data[i]))
+ for (i = 0; line->data[i] != '\0'; i++) {
+ if (!IsSpecialAttrChar(line->data[i])) {
fputc(line->data[i],fp);
-
+ } else if (line->data[i] == LY_SOFT_HYPHEN &&
+ line->data[i + 1] == '\0') { /* last char on line */
+ if (dump_output_immediately &&
+ LYRawMode &&
+ LYlowest_eightbit[current_char_set] <= 173 &&
+ (current_char_set == 0 ||
+ LYCharSet_UC[current_char_set].enc == UCT_ENC_8859 ||
+ LYCharSet_UC[current_char_set].like8859 & UCT_R_8859SPECL)) {
+ fputc(0xad, fp); /* the iso8859 byte for SHY */
+ } else {
+ fputc('-', fp);
+ }
+ }
+ }
/*
* Add the return.
*/
diff --git a/src/GridText.h b/src/GridText.h
index 92c2d40f..fbd8455d 100644
--- a/src/GridText.h
+++ b/src/GridText.h
@@ -71,6 +71,10 @@ extern void HText_setStale PARAMS((HText * text));
extern void HText_refresh PARAMS((HText * text));
extern char * HText_getTitle NOPARAMS;
extern char * HText_getSugFname NOPARAMS;
+extern void HTCheckFnameForCompression PARAMS((
+ char ** fname,
+ HTParentAnchor * anchor,
+ BOOLEAN strip_ok));
extern char * HText_getLastModified NOPARAMS;
extern char * HText_getDate NOPARAMS;
extern char * HText_getServer NOPARAMS;
diff --git a/src/HTAlert.c b/src/HTAlert.c
index 926a2b71..93fb0fed 100644
--- a/src/HTAlert.c
+++ b/src/HTAlert.c
@@ -421,39 +421,75 @@ PUBLIC BOOL HTConfirmCookie ARGS6(
**
** On entry,
** Redirecting_url is the Location.
+** server_status is the server status code.
**
** On exit,
** Returns 0 on cancel,
** 1 for redirect of POST with content,
** 303 for redirect as GET without content
*/
-PUBLIC int HTConfirmPostRedirect ARGS1(
- CONST char *, Redirecting_url)
+PUBLIC int HTConfirmPostRedirect ARGS2(
+ CONST char *, Redirecting_url,
+ int, server_status)
{
char *show_POST_url = NULL;
+ char StatusInfo[256];
char url[256];
int on_screen = 0; /* 0 - show menu
* 1 - show url
* 2 - menu is already on screen */
- if (dump_output_immediately)
+ if (server_status == 303 ||
+ server_status == 302) {
/*
- ** Treat as 303 (GET without content) if not interactive.
- */
- return 303;
+ * HTTP.c should not have called us for either of
+ * these because we're treating 302 as historical,
+ * so just return 303. - FM
+ */
+ return 303;
+ }
+
+ if (dump_output_immediately)
+ if (server_status == 301) {
+ /*
+ ** Treat 301 as historical, i.e., like 303 (GET
+ ** without content), when not interactive. - FM
+ */
+ return 303;
+ } else {
+ /*
+ ** Treat anything else (e.g., 305, 306 or 307) as too
+ ** dangerous to redirect without confirmation, and thus
+ ** cancel when not interactive. - FM
+ */
+ return 0;
+ }
+ StatusInfo[254] = StatusInfo[255] = '\0';
+ url[254] = url[(LYcols < 250 ? LYcols-1 : 255)] = '\0';
if (user_mode == NOVICE_MODE) {
on_screen = 2;
move(LYlines-2, 0);
- addstr(SERVER_ASKED_FOR_REDIRECTION);
+ sprintf(StatusInfo, SERVER_ASKED_FOR_REDIRECTION, server_status);
+ addstr(StatusInfo);
clrtoeol();
move(LYlines-1, 0);
sprintf(url, "URL: %.*s",
(LYcols < 250 ? LYcols-6 : 250), Redirecting_url);
addstr(url);
clrtoeol();
- _statusline(PROCEED_GET_CANCEL);
+ if (server_status == 301) {
+ _statusline(PROCEED_GET_CANCEL);
+ } else {
+ _statusline(PROCEED_OR_CANCEL);
+ }
} else {
+ sprintf(StatusInfo, "%d %.*s",
+ server_status,
+ 251,
+ ((server_status == 301) ?
+ ADVANCED_POST_GET_REDIRECT :
+ ADVANCED_POST_REDIRECT));
StrAllocCopy(show_POST_url, LOCATION_HEADER);
StrAllocCat(show_POST_url, Redirecting_url);
}
@@ -462,7 +498,7 @@ PUBLIC int HTConfirmPostRedirect ARGS1(
switch (on_screen) {
case 0:
- _statusline(ADVANCED_POST_REDIRECT);
+ _statusline(StatusInfo);
break;
case 1:
_statusline(show_POST_url);
@@ -471,8 +507,8 @@ PUBLIC int HTConfirmPostRedirect ARGS1(
switch (TOUPPER(c)) {
case 'P':
/*
- ** Proceed with 301 or 302 redirect of POST
- ** (we check only for 0 and 303 in HTTP.c).
+ ** Proceed with 301 or 307 redirect of POST
+ ** with same method and POST content. - FM
*/
FREE(show_POST_url);
return 1;
@@ -480,37 +516,43 @@ PUBLIC int HTConfirmPostRedirect ARGS1(
case 7:
case 'C':
/*
- ** Cancel request.
+ ** Cancel request.
*/
FREE(show_POST_url);
return 0;
- case 'G':
- /*
- ** Treat as 303 (GET without content).
- */
- FREE(show_POST_url);
- return 303;
-
case 'U':
/*
** Show URL for intermediate or advanced mode.
*/
- if (user_mode != NOVICE_MODE)
- if (on_screen == 1)
+ if (user_mode != NOVICE_MODE) {
+ if (on_screen == 1) {
on_screen = 0;
- else
+ } else {
on_screen = 1;
+ }
+ }
break;
+ case 'G':
+ if (server_status == 301) {
+ /*
+ ** Treat as 303 (GET without content).
+ */
+ FREE(show_POST_url);
+ return 303;
+ }
+ /* fall through to default */
+
default:
/*
** Get another character.
*/
- if (on_screen == 1)
+ if (on_screen == 1) {
on_screen = 0;
- else
+ } else {
on_screen = 2;
+ }
}
}
}
diff --git a/src/HTAlert.h b/src/HTAlert.h
index 744a2a35..bb07b2a1 100644
--- a/src/HTAlert.h
+++ b/src/HTAlert.h
@@ -112,6 +112,7 @@ extern BOOL HTConfirmCookie PARAMS((
** ----------------------------
** On entry,
** Redirecting_url is the Location.
+** server_status is the server status code.
**
** On exit,
** Returns 0 on cancel,
@@ -119,7 +120,8 @@ extern BOOL HTConfirmCookie PARAMS((
** 303 for redirect as GET without content
*/
extern int HTConfirmPostRedirect PARAMS((
- CONST char * Redirecting_url));
+ CONST char * Redirecting_url,
+ int server_status));
/*
diff --git a/src/HTFWriter.c b/src/HTFWriter.c
index 93e75a68..5f41becb 100644
--- a/src/HTFWriter.c
+++ b/src/HTFWriter.c
@@ -72,6 +72,7 @@ struct _HTStream {
FILE * fp; /* The file we've opened */
char * end_command; /* What to do on _free. */
char * remove_command; /* What to do on _abort. */
+ char * viewer_command; /* saved external viewer */
HTFormat input_format; /* Original pres->rep */
HTFormat output_format; /* Original pres->rep_out */
HTParentAnchor * anchor; /* Original stream's anchor. */
@@ -124,7 +125,7 @@ PRIVATE void HTFWriter_write ARGS3(HTStream *, me, CONST char*, s, int, l)
*/
PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
{
- FILE *fp;
+ FILE *fp = NULL;
int len;
char *path = NULL;
char *addr = NULL;
@@ -132,6 +133,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
extern int HTLoadFile PARAMS((
CONST char *addr, HTParentAnchor *anchor,
HTFormat format_out, HTStream *sink));
+ BOOL use_gzread = NO;
fflush(me->fp);
if (me->end_command) { /* Temp file */
@@ -162,6 +164,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
* a temporary file for uncompression. - FM
*/
if (me->anchor->FileCache != NULL) {
+ BOOL skip_loadfile = (me->viewer_command != NULL);
/*
* Save the path with the "gz" or "Z" suffix trimmed,
* and remove any previous uncompressed copy. - FM
@@ -169,27 +172,38 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
StrAllocCopy(path, me->anchor->FileCache);
if ((len = strlen(path)) > 2) {
if (!strcasecomp((char *)&path[len-2], "gz")) {
- path[len-3] = '\0';
- remove(path);
+#ifdef USE_ZLIB
+ if (!skip_loadfile) {
+ use_gzread = YES;
+ } else
+#endif /* USE_ZLIB */
+ {
+ path[len-3] = '\0';
+ remove(path);
+ }
} else if (!strcasecomp((char *)&path[len-1], "Z")) {
path[len-2] = '\0';
remove(path);
}
}
- if (!dump_output_immediately) {
+ if (!use_gzread) {
+ if (!dump_output_immediately) {
+ /*
+ * Tell user what's happening. - FM
+ */
+ _HTProgress(me->end_command);
+ }
/*
- * Tell user what's happening. - FM
+ * Uncompress it. - FM
*/
- _HTProgress(me->end_command);
+ if (me->end_command && me->end_command[0])
+ system(me->end_command);
+ fp = fopen(me->anchor->FileCache, "r");
}
- /*
- * Uncompress it. - FM
- */
- system(me->end_command);
- if ((fp = fopen(me->anchor->FileCache, "r")) != NULL) {
+ if (fp != NULL) {
/*
- * It's still there with the "gz" of "Z" suffix,
- * so the uncompression failed. - FM
+ * It's still there with the "gz" of "Z" suffix when
+ * it shouldn't, so the uncompression failed. - FM
*/
fclose(fp);
fp = NULL;
@@ -217,19 +231,23 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
StrAllocCat(addr, path);
#endif /* VMS */
#endif /* DOSPATH */
- StrAllocCopy(me->anchor->FileCache, path);
+ if (!use_gzread) {
+ StrAllocCopy(me->anchor->FileCache, path);
+ FREE(me->anchor->content_encoding);
+ }
FREE(path);
- FREE(me->anchor->content_encoding);
#ifdef EXP_CHARTRANS
/*
* Lock the chartrans info we may possibly have,
* so HTCharsetFormat() will not apply the default
* for local files. - KW
*/
- HTAnchor_copyUCInfoStage(me->anchor,
- UCT_STAGE_PARSER,
- UCT_STAGE_MIME,
- UCT_SETBY_PARSER);
+ if (!skip_loadfile) {
+ HTAnchor_copyUCInfoStage(me->anchor,
+ UCT_STAGE_PARSER,
+ UCT_STAGE_MIME,
+ UCT_SETBY_PARSER);
+ }
#endif
/*
* Now have HTLoadFile() handle the uncompressed
@@ -241,6 +259,49 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
*/
_user_message(WWW_USING_MESSAGE, addr);
}
+
+ if (skip_loadfile) {
+ /*
+ * It's a temporary file we're passing to a
+ * viewer or helper application.
+ * Loading the temp file through HTLoadFile()
+ * would result in yet another HTStream (created
+ * with HTSaveAndExecute()) which would just
+ * copy the temp file to another temp file
+ * (or even the same!). We can skip this
+ * needless duplication by using the
+ * viewer_command which has already been
+ * determind when the HTCompressed stream was
+ * created. - kw
+ */
+ FREE(me->end_command);
+ me->end_command = (char *)calloc (
+ (strlen (me->viewer_command) + 10 +
+ strlen(me->anchor->FileCache))
+ * sizeof (char),1);
+ if (me->end_command == NULL)
+ outofmem(__FILE__, "HTFWriter_free (HTCompressed)");
+
+ sprintf(me->end_command,
+ me->viewer_command, me->anchor->FileCache,
+ "", "", "", "", "", "");
+ if (!dump_output_immediately) {
+ /*
+ * Tell user what's happening. - FM
+ */
+ HTProgress(me->end_command);
+ stop_curses();
+ }
+ system(me->end_command);
+
+ if (me->remove_command) {
+ /* NEVER REMOVE THE FILE unless during an abort!!!*/
+ /* system(me->remove_command); */
+ FREE(me->remove_command);
+ }
+ if (!dump_output_immediately)
+ start_curses();
+ } else
status = HTLoadFile(addr,
me->anchor,
me->output_format,
@@ -252,6 +313,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
FREE(me->anchor->FileCache);
FREE(me->remove_command);
FREE(me->end_command);
+ FREE(me->viewer_command);
FREE(me);
return;
}
@@ -298,6 +360,7 @@ PRIVATE void HTFWriter_free ARGS1(HTStream *, me)
}
FREE(me->end_command);
}
+ FREE(me->viewer_command);
if (dump_output_immediately) {
if (me->anchor->FileCache)
@@ -330,6 +393,7 @@ PRIVATE void HTFWriter_abort ARGS2(HTStream *, me, HTError, e)
fprintf(stderr,"HTFWriter_abort called\n");
fclose(me->fp);
+ FREE(me->viewer_command);
if (me->end_command) { /* Temp file */
if (TRACE)
fprintf(stderr, "HTFWriter: Aborting: file not executed.\n");
@@ -523,6 +587,7 @@ SaveAndExecute_tempname:
}
chmod(fnam, 0600);
+ StrAllocCopy(me->viewer_command, pres->command);
/*
* Make command to process file.
*/
@@ -773,7 +838,8 @@ SaveToFile_tempname:
StrAllocCopy(anchor->FileCache, fnam);
Prepend_BASE:
- if (!strncasecomp(pres->rep->name, "text/html", 9)) {
+ if (!strncasecomp(pres->rep->name, "text/html", 9) &&
+ !anchor->content_encoding) {
/*
* Add the document's base as a BASE tag at the top of the file,
* so that any partial or relative URLs within it will be resolved
@@ -986,13 +1052,44 @@ Compressed_tempname:
chmod(fnam, 0600);
/*
+ * me->viewer_command will be NULL if the converter Pres found above
+ * is not for an external viewer but an internal HTStream converter.
+ * We also don't set it under conditions where HTSaveAndExecute would
+ * disallow execution of the command. - kw
+ */
+ if (!dump_output_immediately && !traversal
+#if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
+ && (Pres->quality != 999.0 ||
+ (!no_exec && /* allowed exec link or script ? */
+ (local_exec ||
+ (local_exec_on_local_files &&
+ (LYJumpFileURL ||
+ !strncmp(anchor->address,"file://localhost",16))))))
+#endif /* EXEC_LINKS || EXEC_SCRIPTS */
+ ) {
+ StrAllocCopy(me->viewer_command, Pres->command);
+ }
+
+ /*
* Make command to process file. - FM
*/
- me->end_command = (char *)calloc(1, (strlen(uncompress_mask) + 10 +
- strlen(fnam)) * sizeof(char));
- if (me->end_command == NULL)
- outofmem(__FILE__, "HTCompressed");
- sprintf(me->end_command, uncompress_mask, fnam, "", "", "", "", "", "");
+#if USE_ZLIB
+ if (compress_suffix[0] == 'g' && /* must be gzip */
+ !me->viewer_command) {
+ /*
+ * We won't call gzip externally, so we don't need to supply
+ * a command for it. - kw
+ */
+ StrAllocCopy(me->end_command, "");
+ } else
+#endif /* USE_ZLIB */
+ {
+ me->end_command = (char *)calloc(1, (strlen(uncompress_mask) + 10 +
+ strlen(fnam)) * sizeof(char));
+ if (me->end_command == NULL)
+ outofmem(__FILE__, "HTCompressed");
+ sprintf(me->end_command, uncompress_mask, fnam, "", "", "", "", "", "");
+ }
FREE(uncompress_mask);
/*
diff --git a/src/HTFont.h b/src/HTFont.h
index 7b34bbb9..9ab44fd5 100644
--- a/src/HTFont.h
+++ b/src/HTFont.h
@@ -6,7 +6,7 @@
#ifndef HTFONT_H
#define HTFONT_H
-typedef long int HTLMFont; /* For now */
+typedef long int HTMLFont; /* For now */
#define HT_NON_BREAK_SPACE ((char)1) /* For now */
#define HT_EM_SPACE ((char)2) /* For now */
diff --git a/src/HTInit.c b/src/HTInit.c
index e8c74065..5c27d8bf 100644
--- a/src/HTInit.c
+++ b/src/HTInit.c
@@ -60,9 +60,11 @@ PUBLIC void HTFormatInit NOARGS
HTSetPresentation("image/gif", XLoadImageCommand, 1.0, 3.0, 0.0, 0);
HTSetPresentation("image/x-xbm", XLoadImageCommand, 1.0, 3.0, 0.0, 0);
HTSetPresentation("image/x-xbitmap", XLoadImageCommand, 1.0, 3.0, 0.0, 0);
- HTSetPresentation("image/x-png", XLoadImageCommand, 1.0, 3.0, 0.0, 0);
+ HTSetPresentation("image/x-png", XLoadImageCommand, 2.0, 3.0, 0.0, 0);
+ HTSetPresentation("image/png", XLoadImageCommand, 1.0, 3.0, 0.0, 0);
HTSetPresentation("image/x-rgb", XLoadImageCommand, 1.0, 3.0, 0.0, 0);
- HTSetPresentation("image/x-tiff", XLoadImageCommand, 1.0, 3.0, 0.0, 0);
+ HTSetPresentation("image/x-tiff", XLoadImageCommand, 2.0, 3.0, 0.0, 0);
+ HTSetPresentation("image/tiff", XLoadImageCommand, 1.0, 3.0, 0.0, 0);
HTSetPresentation("image/jpeg", XLoadImageCommand, 1.0, 3.0, 0.0, 0);
HTSetPresentation("video/mpeg", "mpeg_play %s &", 1.0, 3.0, 0.0, 0);
@@ -810,7 +812,7 @@ PUBLIC void HTFileInit NOARGS
HTSetSuffix(".pbm", "image/x-portable-bitmap", "binary", 1.0);
HTSetSuffix(".pgm", "image/x-portable-graymap", "binary", 1.0);
HTSetSuffix(".ppm", "image/x-portable-pixmap", "binary", 1.0);
- HTSetSuffix(".png", "image/x-png", "binary", 1.0);
+ HTSetSuffix(".png", "image/png", "binary", 1.0);
HTSetSuffix(".rgb", "image/x-rgb", "binary", 1.0);
HTSetSuffix(".xbm", "image/x-xbitmap", "binary", 1.0);
HTSetSuffix(".xpm", "image/x-xpixmap", "binary", 1.0);
@@ -842,6 +844,7 @@ PUBLIC void HTFileInit NOARGS
HTSetSuffix(".htm", "text/html", "8bit", 1.0);
HTSetSuffix(".html3", "text/html", "8bit", 1.0);
HTSetSuffix(".ht3", "text/html", "8bit", 1.0);
+ HTSetSuffix(".phtml", "text/html", "8bit", 1.0);
HTSetSuffix(".shtml", "text/html", "8bit", 1.0);
HTSetSuffix(".htmlx", "text/html", "8bit", 1.0);
HTSetSuffix(".html", "text/html", "8bit", 1.0);
diff --git a/src/HTML.c b/src/HTML.c
index 4de030c8..4a60ac9a 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -546,11 +546,11 @@ PRIVATE void HTML_start_element ARGS5(
strcat (Style_className, class_string);
strcat (myHash, ".");
strcat (myHash, class_string);
-#if !defined(PREVAIL)
- }
-#else /* PREVAIL */
+#ifdef PREVAIL
strcpy (prevailing_class, class_string);
+#endif
}
+#ifdef PREVAIL
else if (prevailing_class[0])
{
strcat (Style_className, ".");
@@ -558,7 +558,7 @@ PRIVATE void HTML_start_element ARGS5(
strcat (myHash, ".");
strcat (myHash, prevailing_class);
}
-#endif /* !PREVAIL */
+#endif /* PREVAIL */
class_string[0]='\0';
strtolower(myHash);
hcode=hash_code(myHash);
@@ -2031,8 +2031,8 @@ PRIVATE void HTML_start_element ARGS5(
/*
* Set the default TYPE.
*/
- me->OL_Type[(me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6)] = '1';
+ me->OL_Type[(me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11)] = '1';
/*
* Check whether we have a starting sequence number,
@@ -2065,23 +2065,23 @@ PRIVATE void HTML_start_element ARGS5(
*/
if (present[HTML_OL_TYPE] && value[HTML_OL_TYPE]) {
if (*value[HTML_OL_TYPE] == 'A') {
- me->OL_Type[(me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6)] = 'A';
+ me->OL_Type[(me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11)] = 'A';
if (seqnum < 1)
seqnum = 1;
} else if (*value[HTML_OL_TYPE] == 'a') {
- me->OL_Type[(me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6)] = 'a';
+ me->OL_Type[(me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11)] = 'a';
if (seqnum < 1)
seqnum = 1;
} else if (*value[HTML_OL_TYPE] == 'I') {
- me->OL_Type[(me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6)] = 'I';
+ me->OL_Type[(me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11)] = 'I';
if (seqnum < 1)
seqnum = 1;
} else if (*value[HTML_OL_TYPE] == 'i') {
- me->OL_Type[(me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6)] = 'i';
+ me->OL_Type[(me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11)] = 'i';
if (seqnum < 1)
seqnum = 1;
} else {
@@ -2092,29 +2092,29 @@ PRIVATE void HTML_start_element ARGS5(
seqnum = OL_VOID + 1;
}
- me->OL_Counter[(me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6)] = seqnum;
+ me->OL_Counter[(me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11)] = seqnum;
} else if (present && present[HTML_OL_CONTINUE]) {
- me->OL_Counter[me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6] = OL_CONTINUE;
+ me->OL_Counter[me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11] = OL_CONTINUE;
} else {
- me->OL_Counter[(me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6)] = 1;
+ me->OL_Counter[(me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11)] = 1;
if (present && present[HTML_OL_TYPE] && value[HTML_OL_TYPE]) {
if (*value[HTML_OL_TYPE] == 'A') {
- me->OL_Type[(me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6)] = 'A';
+ me->OL_Type[(me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11)] = 'A';
} else if (*value[HTML_OL_TYPE] == 'a') {
- me->OL_Type[(me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6)] = 'a';
+ me->OL_Type[(me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11)] = 'a';
} else if (*value[HTML_OL_TYPE] == 'I') {
- me->OL_Type[(me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6)] = 'I';
+ me->OL_Type[(me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11)] = 'I';
} else if (*value[HTML_OL_TYPE] == 'i') {
- me->OL_Type[(me->List_Nesting_Level < 5 ?
- me->List_Nesting_Level+1 : 6)] = 'i';
+ me->OL_Type[(me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level+1 : 11)] = 'i';
}
}
}
@@ -2214,7 +2214,8 @@ PRIVATE void HTML_start_element ARGS5(
int counter, seqnum;
char seqtype;
- counter = me->List_Nesting_Level < 6 ? me->List_Nesting_Level : 6;
+ counter = me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level : 11;
if (present && present[HTML_LI_TYPE] && value[HTML_LI_TYPE]) {
if (*value[HTML_LI_TYPE] == '1') {
me->OL_Type[counter] = '1';
@@ -5855,20 +5856,22 @@ PRIVATE void HTML_end_element ARGS3(
break;
case HTML_OL:
- me->OL_Counter[me->List_Nesting_Level < 6 ?
- me->List_Nesting_Level : 6] = OL_VOID;
+ me->OL_Counter[me->List_Nesting_Level < 11 ?
+ me->List_Nesting_Level : 11] = OL_VOID;
case HTML_DL:
case HTML_UL:
case HTML_MENU:
case HTML_DIR:
me->List_Nesting_Level--;
- if (TRACE)
- fprintf(stderr, "Reducing List Nesting Level to %d\n",
- me->List_Nesting_Level);
+ if (TRACE) {
+ fprintf(stderr,
+ "HTML_end_element: Reducing List Nesting Level to %d\n",
+ me->List_Nesting_Level);
+ }
change_paragraph_style(me, me->sp->style); /* Often won't really change */
UPDATE_STYLE;
if (me->List_Nesting_Level >= 0)
- HText_NegateLineOne(me->text);
+ LYEnsureSingleSpace(me);
break;
case HTML_SPAN:
@@ -7151,7 +7154,7 @@ PUBLIC HTStructured* HTML_new ARGS3(
* Used for nested lists. - FM
*/
me->List_Nesting_Level = -1; /* counter for list nesting level */
- LYZero_OL_Counter(me); /* Initializes OL_Counter[7] and OL_Type[7] */
+ LYZero_OL_Counter(me); /* Initializes OL_Counter[] and OL_Type[] */
me->Last_OL_Count = 0; /* last count in ordered lists */
me->Last_OL_Type = '1'; /* last type in ordered lists */
diff --git a/src/HTML.h b/src/HTML.h
index 8d313e81..0061f7d4 100644
--- a/src/HTML.h
+++ b/src/HTML.h
@@ -88,8 +88,8 @@ struct _HTStructured {
* Used for nested lists. - FM
*/
int List_Nesting_Level; /* counter for list nesting level */
- int OL_Counter[7]; /* counter for ordered lists */
- char OL_Type[7]; /* types for ordered lists */
+ int OL_Counter[12]; /* counter for ordered lists */
+ char OL_Type[12]; /* types for ordered lists */
int Last_OL_Count; /* last count in ordered lists */
char Last_OL_Type; /* last type in ordered lists */
diff --git a/src/LYCharUtils.c b/src/LYCharUtils.c
index b7d82c97..8ee363e8 100644
--- a/src/LYCharUtils.c
+++ b/src/LYCharUtils.c
@@ -9,6 +9,7 @@
#include "HTChunk.h"
#include "HText.h"
#include "HTStyle.h"
+#include "HTMIME.h"
#include "HTML.h"
#include "HTCJK.h"
@@ -1673,7 +1674,7 @@ PUBLIC void LYZero_OL_Counter ARGS1(
if (!me)
return;
- for (i = 0; i < 7; i++) {
+ for (i = 0; i < 12; i++) {
me->OL_Counter[i] = OL_VOID;
me->OL_Type[i] = '1';
}
@@ -2227,25 +2228,37 @@ PUBLIC void LYHandleMETA ARGS4(
/*
* Check for a suggested filename via a Content-Disposition with
- * file; filename=name.suffix in it, if we don't already have it
+ * a filename=name.suffix in it, if we don't already have it
* via a server header. - FM
*/
} else if (!(me->node_anchor->SugFname && *me->node_anchor->SugFname) &&
!strcasecomp((http_equiv ?
http_equiv : ""), "Content-Disposition")) {
cp = content;
- while (*cp != '\0' && strncasecomp(cp, "file;", 5))
+ while (*cp != '\0' && strncasecomp(cp, "filename", 8))
cp++;
if (*cp != '\0') {
- cp += 5;
+ cp += 8;
+ while ((*cp != '\0') && (WHITE(*cp) || *cp == '='))
+ cp++;
while (*cp != '\0' && WHITE(*cp))
cp++;
if (*cp != '\0') {
- while (*cp != '\0' && strncasecomp(cp, "filename=", 9))
- cp++;
- if (*cp != '\0') {
- StrAllocCopy(me->node_anchor->SugFname, (cp + 9));
- cp = me->node_anchor->SugFname;
+ StrAllocCopy(me->node_anchor->SugFname, cp);
+ if (*me->node_anchor->SugFname == '\"') {
+ if ((cp = strchr((me->node_anchor->SugFname + 1),
+ '\"')) != NULL) {
+ *(cp + 1) = '\0';
+ HTMIME_TrimDoubleQuotes(me->node_anchor->SugFname);
+ } else {
+ FREE(me->node_anchor->SugFname);
+ }
+ if (me->node_anchor->SugFname != NULL &&
+ *me->node_anchor->SugFname == '\0') {
+ FREE(me->node_anchor->SugFname);
+ }
+ }
+ if ((cp = me->node_anchor->SugFname) != NULL) {
while (*cp != '\0' && !WHITE(*cp))
cp++;
*cp = '\0';
@@ -2685,54 +2698,64 @@ PUBLIC int LYLegitimizeHREF ARGS4(
"http", 4)) {
/*
* We will be resolving a partial reference versus an http
- * or https URL, and it has lead dots, which are retained
- * when resolving, in compliance with the URL specs, but
- * the request would fail if the first element of the
- * resultant path is two dots, because no http or https
- * server accepts such paths, so if that's the case, and
- * strip_dots is TRUE, we'll strip that element now, but
- * issue a message about this as "immediate feedback",
- * such that the bad partial reference might get corrected
- * by the document provider. Note that if the second and
- * further symbolic elements also contain(s) only dots,
- * those will still be retained, and the resolved URL may
- * still fail, but it should, IMHO, if the partial reference
- * is that much out of compliance with the URL specs. - FM
+ * or https URL, and it has lead dots, which may be retained
+ * when resolving via HTParse(), but the request would fail
+ * if the first element of the resultant path is two dots,
+ * because no http or https server accepts such paths, and
+ * the current URL draft, likely to become an RFC, says that
+ * it's optional for the UA to strip them as a form of error
+ * recovery. So we will, recursively, for http/https URLs,
+ * like the "major market browsers" which made this problem
+ * so common on the Web, but we'll also issue a message about
+ * it, such that the bad partial reference might get corrected
+ * by the document provider. - FM
*/
int i = 0, j = 0;
- char *temp = NULL, *str = "";
+ char *temp = NULL, *path = NULL, *str = "", *cp;
- if (((temp = HTParse((me->inBASE ?
+ if (((temp = HTParse(*href,
+ (me->inBASE ?
me->base_href : me->node_anchor->address),
- "", PARSE_PATH+PARSE_PUNCTUATION)) == NULL) ||
- temp[0] == '\0' ||
- !strchr((char *)&temp[1], '/')) {
- FREE(temp);
- temp = *href;
- if ((me->inBASE ?
- me->base_href[4] : me->node_anchor->address[4]) == 's')
- str = "s";
- while (temp[j] == '.')
- j++;
- if ((j == 2) && (temp[j] == '/' || temp[j] == '\0')) {
+ PARSE_ALL)) != NULL && temp[0] != '\0') &&
+ (path = HTParse(temp, "",
+ PARSE_PATH+PARSE_PUNCTUATION)) != NULL &&
+ !strncmp(path, "/..", 3)) {
+ cp = (path + 3);
+ if (*cp == '/' || *cp == '\0') {
+ if ((me->inBASE ?
+ me->base_href[4] : me->node_anchor->address[4]) == 's') {
+ str = "s";
+ }
if (TRACE) {
fprintf(stderr,
"LYLegitimizeHREF: Bad value '%s' for http%s URL.\n",
*href, str);
fprintf(stderr,
- " Stripping lead dots.\n");
+ " Stripping lead dots.\n");
} else if (!me->inBadHREF) {
_statusline(BAD_PARTIAL_REFERENCE);
me->inBadHREF = TRUE;
sleep(AlertSecs);
}
- while (temp[j] != '\0')
- temp[i++] = temp[j++];
- temp[i] = '\0';
}
- temp = NULL;
+ if (*cp == '\0') {
+ StrAllocCopy(*href, "/");
+ } else if (*cp == '/') {
+ while (!strncmp(cp, "/..", 3)) {
+ if (*(cp + 3) == '/') {
+ cp += 3;
+ continue;
+ } else if (*(cp + 3) == '\0') {
+ *(cp + 1) = '\0';
+ *(cp + 2) = '\0';
+ }
+ break;
+ }
+ StrAllocCopy(*href, cp);
+ }
}
FREE(temp);
+ FREE(path);
}
return(url_type);
}
diff --git a/src/LYCookie.c b/src/LYCookie.c
index 07d51595..aacd99ac 100644
--- a/src/LYCookie.c
+++ b/src/LYCookie.c
@@ -12,6 +12,10 @@
** http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-state-man-mec-02.txt
** - FM 1997-07-09
**
+** Updated for:
+** ftp://ds.internic.net/internet-drafts/draft-ietf-http-state-man-mec-03.txt
+** - FM 1997-08-02
+**
** TO DO: (roughly in order of decreasing priority)
* A means to specify "always allow" and "never allow" domains via
a configuration file is needed.
@@ -34,8 +38,8 @@
collections to bring us back down under the limits, rather than
actively removing cookies and/or domains based on age or frequency
of use.
- * If the a cookie has the secure flag set, we presently treat only
- SSL connections as secure. This may need to be expanded for other
+ * If a cookie has the secure flag set, we presently treat only SSL
+ connections as secure. This may need to be expanded for other
secure communication protocols that become standarized.
* Cookies could be optionally stored in a file from session to session.
*/
@@ -309,7 +313,9 @@ PRIVATE void store_cookie ARGS3(
/*
* Section 4.3.2, condition 2: The value for the Domain attribute
* contains no embedded dots or does not start with a dot.
- * (A dot is embedded if it's neither the first nor last character.)
+ * (A dot is embedded if it's neither the first nor last character.)
+ * Note that we added a lead dot ourselves if a domain attribute
+ * value otherwise qualified. - FM
*/
if (co->domain[0] != '.' || co->domain[1] == '\0') {
if (TRACE)
@@ -682,31 +688,24 @@ PRIVATE void LYProcessSetCookies ARGS6(
/*
* If we have both Set-Cookie and Set-Cookie2 headers.
- * process the Set-Cookie2 header, then the Set-Cookie
- * header. The most current draft has abandoned the
- * the earlier requirement to combine them, but we'll
- * keep doing that for now, until we're sure that holds
- * up, since we never replace anything that was in the
- * Set-Cookie2 headers with it's equivalent in the
- * Set-Cookie header. If we have only a Set-Cookie2
- * or only a Set-Cookie header, that's what we use. So
- * set up a list for the cookies we process out of the
- * header(s). Note that if more than one instance of a
- * valued attribute for the same cookie is encountered,
- * even within the same header, the value for the first
- * instance is retained, with consequent preference to
- * that in a Set-Cookie2 header, since that was processed
- * first. We only accept up to 50 cookies from either
- * header, and only if a cookie's values do not exceed
- * the 4096 byte limit on overall size. - FM
+ * process the Set-Cookie2 header. Otherwise, process
+ * whichever of the two headers we do have. Note that
+ * if more than one instance of a valued attribute for
+ * the same cookie is encountered, the value for the
+ * first instance is retained. We only accept up to 50
+ * cookies from the header, and only if a cookie's values
+ * do not exceed the 4096 byte limit on overall size. - FM
*/
CombinedCookies = HTList_new();
/*
- * First process the Set-Cookie2 header, if present, adding
- * each cookie to the CombinedCookies list. - FM
+ * Process the Set-Cookie2 header, if present and not zero-length,
+ * adding each cookie to the CombinedCookies list. - FM
*/
p = (SetCookie2 ? SetCookie2 : "");
+ if (TRACE && SetCookie && *p) {
+ fprintf(stderr, "LYProcessSetCookies: Using Set-Cookie2 header.\n");
+ }
while (NumCookies <= 50 && *p) {
attr_start = attr_end = value_start = value_end = NULL;
while (*p != '\0' && isspace((unsigned char)*p)) {
@@ -955,23 +954,17 @@ PRIVATE void LYProcessSetCookies ARGS6(
address,
PARSE_ALL);
/*
- * Accept only URLs for servers. - FM
+ * Accept only URLs for http or https servers. - FM
*/
if ((url_type = is_url(cur_cookie->commentURL)) &&
(url_type == HTTP_URL_TYPE ||
- url_type == HTTPS_URL_TYPE ||
- url_type == FTP_URL_TYPE ||
- url_type == GOPHER_URL_TYPE ||
- url_type == HTML_GOPHER_URL_TYPE ||
- url_type == INDEX_GOPHER_URL_TYPE ||
- url_type == NEWS_URL_TYPE ||
- url_type == NNTP_URL_TYPE ||
- url_type == SNEWS_URL_TYPE ||
- url_type == WAIS_URL_TYPE ||
- url_type == CSO_URL_TYPE ||
- url_type == FINGER_URL_TYPE)) {
+ url_type == HTTPS_URL_TYPE)) {
length += strlen(cur_cookie->commentURL);
} else {
+ if (TRACE)
+ fprintf(stderr,
+ "LYProcessSetCookies: Rejecting commentURL value '%s'\n",
+ cur_cookie->commentURL);
FREE(cur_cookie->commentURL);
}
}
@@ -983,7 +976,38 @@ PRIVATE void LYProcessSetCookies ARGS6(
*/
!(cur_cookie->flags & COOKIE_FLAG_DOMAIN_SET)) {
length -= strlen(cur_cookie->domain);
- StrAllocCopy(cur_cookie->domain, value);
+ /*
+ * If the value does not have a lead dot,
+ * but does have an embedded dot, and is
+ * not an exact match to the hostname, nor
+ * is a numeric IP address, add a lead dot.
+ * Otherwise, use the value as is. - FM
+ */
+ if (value[0] != '.' && value[0] != '\0' &&
+ value[1] != '\0' && strcmp(value, hostname)) {
+ char *ptr = strchr(value, '.');
+ if (ptr != NULL && ptr[1] != '\0') {
+ ptr = value;
+ while (*ptr == '.' ||
+ isdigit((unsigned char)*ptr))
+ ptr++;
+ if (*ptr != '\0') {
+ if (TRACE) {
+ fprintf(stderr,
+ "LYProcessSetCookies: Adding lead dot for domain value '%s'\n",
+ value);
+ }
+ StrAllocCopy(cur_cookie->domain, ".");
+ StrAllocCat(cur_cookie->domain, value);
+ } else {
+ StrAllocCopy(cur_cookie->domain, value);
+ }
+ } else {
+ StrAllocCopy(cur_cookie->domain, value);
+ }
+ } else {
+ StrAllocCopy(cur_cookie->domain, value);
+ }
length += strlen(cur_cookie->domain);
cur_cookie->flags |= COOKIE_FLAG_DOMAIN_SET;
}
@@ -1091,7 +1115,7 @@ PRIVATE void LYProcessSetCookies ARGS6(
}
/*
- * If none of the above comparisions succeeded, and we have
+ * If none of the above comparisons succeeded, and we have
* a value, then we have an unknown pair of the form 'foo=bar',
* which means it's time to create a new cookie. If we don't
* have a non-zero-length value, assume it's an error or a
@@ -1111,6 +1135,19 @@ PRIVATE void LYProcessSetCookies ARGS6(
cur_cookie->version = 1;
}
HTList_appendObject(CombinedCookies, cur_cookie);
+ } else if (cur_cookie != NULL) {
+ if (TRACE) {
+ fprintf(stderr,
+ "LYProcessSetCookies: Rejecting Set-Cookie2: %s=%s\n",
+ (cur_cookie->name ?
+ cur_cookie->name : "[no name]"),
+ (cur_cookie->value ?
+ cur_cookie->value : "[no value]"));
+ fprintf(stderr,
+ " due to excessive length!\n");
+ }
+ freeCookie(cur_cookie);
+ cur_cookie = NULL;
}
/*
* Start a new cookie. - FM
@@ -1160,14 +1197,16 @@ PRIVATE void LYProcessSetCookies ARGS6(
}
/*
- * Now process the Set-Cookie header, if present, checking the
- * CombinedCookies list for a corresponding cookie and supplementing
- * that if one is present, otherwise, adding the new cookie. - FM
+ * Process the Set-Cookie header, if no non-zero-length Set-Cookie2
+ * header was present. - FM
*/
length = 0;
NumCookies = 0;
cur_cookie = NULL;
- p = (SetCookie ? SetCookie : "");
+ p = ((SetCookie && !(SetCookie2 && *SetCookie2)) ? SetCookie : "");
+ if (TRACE && SetCookie2 && *p) {
+ fprintf(stderr, "LYProcessSetCookies: Using Set-Cookie header.\n");
+ }
while (NumCookies <= 50 && *p) {
attr_start = attr_end = value_start = value_end = NULL;
while (*p != '\0' && isspace((unsigned char)*p)) {
@@ -1413,25 +1452,17 @@ PRIVATE void LYProcessSetCookies ARGS6(
address,
PARSE_ALL);
/*
- * Accept only URLs for servers. The most
- * recent draft says just http, so the others
- * are commented out here. - FM
+ * Accept only URLs for http or https servers. - FM
*/
if ((url_type = is_url(cur_cookie->commentURL)) &&
(url_type == HTTP_URL_TYPE ||
- url_type == HTTPS_URL_TYPE/* ||
- url_type == FTP_URL_TYPE ||
- url_type == GOPHER_URL_TYPE ||
- url_type == HTML_GOPHER_URL_TYPE ||
- url_type == INDEX_GOPHER_URL_TYPE ||
- url_type == NEWS_URL_TYPE ||
- url_type == NNTP_URL_TYPE ||
- url_type == SNEWS_URL_TYPE ||
- url_type == WAIS_URL_TYPE ||
- url_type == CSO_URL_TYPE ||
- url_type == FINGER_URL_TYPE */)) {
+ url_type == HTTPS_URL_TYPE)) {
length += strlen(cur_cookie->commentURL);
} else {
+ if (TRACE)
+ fprintf(stderr,
+ "LYProcessSetCookies: Rejecting commentURL value '%s'\n",
+ cur_cookie->commentURL);
FREE(cur_cookie->commentURL);
}
}
@@ -1443,7 +1474,38 @@ PRIVATE void LYProcessSetCookies ARGS6(
*/
!(cur_cookie->flags & COOKIE_FLAG_DOMAIN_SET)) {
length -= strlen(cur_cookie->domain);
- StrAllocCopy(cur_cookie->domain, value);
+ /*
+ * If the value does not have a lead dot,
+ * but does have an embedded dot, and is
+ * not an exact match to the hostname, nor
+ * is a numeric IP address, add a lead dot.
+ * Otherwise, use the value as is. - FM
+ */
+ if (value[0] != '.' && value[0] != '\0' &&
+ value[1] != '\0' && strcmp(value, hostname)) {
+ char *ptr = strchr(value, '.');
+ if (ptr != NULL && ptr[1] != '\0') {
+ ptr = value;
+ while (*ptr == '.' ||
+ isdigit((unsigned char)*ptr))
+ ptr++;
+ if (*ptr != '\0') {
+ if (TRACE) {
+ fprintf(stderr,
+ "LYProcessSetCookies: Adding lead dot for domain value '%s'\n",
+ value);
+ }
+ StrAllocCopy(cur_cookie->domain, ".");
+ StrAllocCat(cur_cookie->domain, value);
+ } else {
+ StrAllocCopy(cur_cookie->domain, value);
+ }
+ } else {
+ StrAllocCopy(cur_cookie->domain, value);
+ }
+ } else {
+ StrAllocCopy(cur_cookie->domain, value);
+ }
length += strlen(cur_cookie->domain);
cur_cookie->flags |= COOKIE_FLAG_DOMAIN_SET;
}
@@ -1534,7 +1596,7 @@ PRIVATE void LYProcessSetCookies ARGS6(
}
/*
- * If none of the above comparisions succeeded, and we have
+ * If none of the above comparisons succeeded, and we have
* a value, then we have an unknown pair of the form 'foo=bar',
* which means it's time to create a new cookie. If we don't
* have a non-zero-length value, assume it's an error or a
@@ -1542,132 +1604,40 @@ PRIVATE void LYProcessSetCookies ARGS6(
* ignore it. - FM
*/
if (!known_attr && value_end > value_start) {
- if (cur_cookie) {
+ /*
+ * If we've started a cookie, and it's not too big,
+ * save it in the CombinedCookies list. - FM
+ */
+ if (length <= 4096 && cur_cookie != NULL) {
+ /*
+ * If we had a Set-Cookie2 header, make sure
+ * the version is at least 1, and mark it for
+ * quoting. - FM
+ */
if (SetCookie2 != NULL) {
- /*
- * If we had a Set-Cookie2 header, make sure
- * the version is at least 1, and mark it for
- * quoting. - FM
- */
if (cur_cookie->version < 1) {
cur_cookie->version = 1;
}
cur_cookie->quoted = TRUE;
}
- cl = CombinedCookies;
- while (NULL != (co = (cookie *)HTList_nextObject(cl))) {
- /*
- * Check whether the cookie from the Set-Cookie2
- * header has the same name and value as this one
- * from the Set-Cookie header. If they both had a
- * domain attribute, make sure those match, and
- * similarly if they both had a path attribute. - FM
- */
- if ((!strcmp(co->name, cur_cookie->name) &&
- !strcmp(co->value, cur_cookie->value)) &&
- !(((co->flags & COOKIE_FLAG_DOMAIN_SET) &&
- (cur_cookie->flags &
- COOKIE_FLAG_DOMAIN_SET)) &&
- strcmp(co->domain, cur_cookie->domain)) &&
- !(((co->flags & COOKIE_FLAG_PATH_SET) &&
- (cur_cookie->flags &
- COOKIE_FLAG_PATH_SET)) &&
- strcmp(co->path, cur_cookie->path))) {
- /*
- * If the Set-Cookie2 header didn't include
- * a domain attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!(co->flags & COOKIE_FLAG_DOMAIN_SET) &&
- (cur_cookie->flags & COOKIE_FLAG_DOMAIN_SET)) {
- StrAllocCopy(co->domain, cur_cookie->domain);
- co->flags |= COOKIE_FLAG_DOMAIN_SET;
- }
- /*
- * If the Set-Cookie2 header didn't include
- * a path attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!(co->flags & COOKIE_FLAG_PATH_SET) &&
- (cur_cookie->flags & COOKIE_FLAG_PATH_SET)) {
- StrAllocCopy(co->path, cur_cookie->path);
- co->pathlen = cur_cookie->pathlen;
- co->flags |= COOKIE_FLAG_PATH_SET;
- }
- /*
- * If the Set-Cookie2 header didn't include
- * a comment attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!co->comment && cur_cookie->comment) {
- StrAllocCopy(co->comment,
- cur_cookie->comment);
- }
- /*
- * If the Set-Cookie2 header didn't include
- * a commentURL attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!co->commentURL && cur_cookie->commentURL) {
- StrAllocCopy(co->commentURL,
- cur_cookie->commentURL);
- }
- /*
- * If the Set-Cookie2 header didn't include
- * a port attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!co->PortList && cur_cookie->PortList) {
- StrAllocCopy(co->PortList,
- cur_cookie->PortList);
- }
- /*
- * If the Set-Cookie2 header didn't include
- * a secure attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!(co->flags & COOKIE_FLAG_SECURE) &&
- (cur_cookie->flags & COOKIE_FLAG_SECURE)) {
- co->flags |= COOKIE_FLAG_SECURE;
- }
- /*
- * If the Set-Cookie2 header didn't set an
- * expiration and the Set-Cookie header did,
- * add it. - FM
- */
- if (!(co->flags & COOKIE_FLAG_EXPIRES_SET) &&
- (cur_cookie->flags &
- COOKIE_FLAG_EXPIRES_SET)) {
- co->expires = cur_cookie->expires;
- co->flags |= COOKIE_FLAG_EXPIRES_SET;
- }
- /*
- * If the Set-Cookie2 header didn't set
- * discard and the Set-Cookie header did,
- * add it. - FM
- */
- if (!(co->flags & COOKIE_FLAG_DISCARD) &&
- (cur_cookie->flags & COOKIE_FLAG_DISCARD)) {
- co->flags |= COOKIE_FLAG_DISCARD;
- }
- /*
- * If the cookie from the Set-Cookie2 header
- * has a lower version than this cookie, use
- * this cookie's version (though it should
- * not have a version number). - FM
- */
- if (co->version < cur_cookie->version) {
- co->version = cur_cookie->version;
- }
- freeCookie(cur_cookie);
- cur_cookie = NULL;
- break;
- }
- }
- if (co == NULL) {
- HTList_appendObject(CombinedCookies, cur_cookie);
+ HTList_appendObject(CombinedCookies, cur_cookie);
+ } else if (cur_cookie != NULL) {
+ if (TRACE) {
+ fprintf(stderr,
+ "LYProcessSetCookies: Rejecting Set-Cookie: %s=%s\n",
+ (cur_cookie->name ?
+ cur_cookie->name : "[no name]"),
+ (cur_cookie->value ?
+ cur_cookie->value : "[no value]"));
+ fprintf(stderr,
+ " due to excessive length!\n");
}
+ freeCookie(cur_cookie);
+ cur_cookie = NULL;
}
+ /*
+ * Start a new cookie. - FM
+ */
cur_cookie = newCookie();
length = 0;
MemAllocCopy(&(cur_cookie->name), attr_start, attr_end);
@@ -1697,113 +1667,7 @@ PRIVATE void LYProcessSetCookies ARGS6(
}
cur_cookie->quoted = TRUE;
}
- cl = CombinedCookies;
- while (NULL != (co = (cookie *)HTList_nextObject(cl))) {
- /*
- * Check whether the cookie from the Set-Cookie2
- * header has the same name and value as this one
- * from the Set-Cookie header. If they both had a
- * domain attribute, make sure those match, and
- * similarly if they both had a path attribute. - FM
- */
- if ((!strcmp(co->name, cur_cookie->name) &&
- !strcmp(co->value, cur_cookie->value)) &&
- !(((co->flags & COOKIE_FLAG_DOMAIN_SET) &&
- (cur_cookie->flags & COOKIE_FLAG_DOMAIN_SET)) &&
- strcmp(co->domain, cur_cookie->domain)) &&
- !(((co->flags & COOKIE_FLAG_PATH_SET) &&
- (cur_cookie->flags & COOKIE_FLAG_PATH_SET)) &&
- strcmp(co->path, cur_cookie->path))) {
- /*
- * If the Set-Cookie2 header didn't include
- * a domain attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!(co->flags & COOKIE_FLAG_DOMAIN_SET) &&
- (cur_cookie->flags & COOKIE_FLAG_DOMAIN_SET)) {
- StrAllocCopy(co->domain, cur_cookie->domain);
- co->flags |= COOKIE_FLAG_DOMAIN_SET;
- }
- /*
- * If the Set-Cookie2 header didn't include
- * a path attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!(co->flags & COOKIE_FLAG_PATH_SET) &&
- (cur_cookie->flags & COOKIE_FLAG_PATH_SET)) {
- StrAllocCopy(co->path, cur_cookie->path);
- co->pathlen = cur_cookie->pathlen;
- co->flags |= COOKIE_FLAG_PATH_SET;
- }
- /*
- * If the Set-Cookie2 header didn't include
- * a comment attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!co->comment && cur_cookie->comment) {
- StrAllocCopy(co->comment, cur_cookie->comment);
- }
- /*
- * If the Set-Cookie2 header didn't include
- * a commentURL attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!co->commentURL && cur_cookie->commentURL) {
- StrAllocCopy(co->commentURL, cur_cookie->commentURL);
- }
- /*
- * If the Set-Cookie2 header didn't include
- * a port attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!co->PortList && cur_cookie->PortList) {
- StrAllocCopy(co->PortList, cur_cookie->PortList);
- }
- /*
- * If the Set-Cookie2 header didn't include
- * a secure attribute and the Set-Cookie
- * header did, add it. - FM
- */
- if (!(co->flags & COOKIE_FLAG_SECURE) &&
- (cur_cookie->flags & COOKIE_FLAG_SECURE)) {
- co->flags |= COOKIE_FLAG_SECURE;
- }
- /*
- * If the Set-Cookie2 header didn't set an
- * expiration and the Set-Cookie header did,
- * add it. - FM
- */
- if (!(co->flags & COOKIE_FLAG_EXPIRES_SET) &&
- (cur_cookie->flags & COOKIE_FLAG_EXPIRES_SET)) {
- co->expires = cur_cookie->expires;
- co->flags |= COOKIE_FLAG_EXPIRES_SET;
- }
- /*
- * If the Set-Cookie2 header didn't set
- * discard and the Set-Cookie header did,
- * add it. - FM
- */
- if (!(co->flags & COOKIE_FLAG_DISCARD) &&
- (cur_cookie->flags & COOKIE_FLAG_DISCARD)) {
- co->flags |= COOKIE_FLAG_DISCARD;
- }
- /*
- * If the cookie from the Set-Cookie2 header
- * has a lower version than this cookie, use
- * this cookie's version (though it should
- * not have a version number). - FM
- */
- if (co->version < cur_cookie->version) {
- co->version = cur_cookie->version;
- }
- freeCookie(cur_cookie);
- cur_cookie = NULL;
- break;
- }
- }
- if (co == NULL) {
- HTList_appendObject(CombinedCookies, cur_cookie);
- }
+ HTList_appendObject(CombinedCookies, cur_cookie);
} else if (cur_cookie != NULL) {
if (TRACE) {
fprintf(stderr,
@@ -1869,8 +1733,8 @@ PUBLIC void LYSetCookie ARGS3(
/*
* Get the hostname, port and path of the address, and report
- * the Set-Cookie request if trace mode is on, but set the cookie
- * only if LYSetCookies is TRUE. - FM
+ * the Set-Cookie and/or Set-Cookie2 header(s) if trace mode is
+ * on, but set the cookie(s) only if LYSetCookies is TRUE. - FM
*/
if (((hostname = HTParse(address, "", PARSE_HOST)) != NULL) &&
(ptr = strchr(hostname, ':')) != NULL) {
diff --git a/src/LYCurses.c b/src/LYCurses.c
index ffffcb1c..41a29cc4 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -575,6 +575,12 @@ PUBLIC void start_curses NOARGS
if (slinit == 0) {
SLtt_get_terminfo();
+#ifdef UNIX
+#if SLANG_VERSION >= 9935
+ SLang_TT_Read_FD = fileno(stdin);
+#endif /* SLANG_VERSION >= 9935 */
+#endif /* UNIX */
+
/*
* Check whether a saved show_color:off override is in effect. - kw
*/
diff --git a/src/LYForms.c b/src/LYForms.c
index 1c053bca..e48a6ca8 100644
--- a/src/LYForms.c
+++ b/src/LYForms.c
@@ -673,6 +673,9 @@ PRIVATE int popup_options ARGS7(
return(orig_selection);
}
scrollok(form_window, TRUE);
+#ifdef PDCURSES
+ keypad(form_window, TRUE);
+#endif /* PDCURSES */
#ifdef NCURSES
#ifdef wgetbkgd
#define getbkgd(w) wgetbkgd(w) /* workaround pre-1.9.9g bug */
diff --git a/src/LYGetFile.c b/src/LYGetFile.c
index f58fcd84..917bb037 100644
--- a/src/LYGetFile.c
+++ b/src/LYGetFile.c
@@ -48,6 +48,7 @@
PRIVATE int fix_http_urls PARAMS((document *doc));
extern char * WWW_Download_File;
extern char LYCancelDownload;
+extern BOOL redirect_post_content;
#ifdef VMS
extern BOOLEAN LYDidRename;
#endif /* VMS */
@@ -127,13 +128,15 @@ Try_Redirected_URL:
redirect_post_content = FALSE;
if (TRACE) {
- fprintf(stderr,"LYGetFile: getting %s\n\n",doc->address);
+ fprintf(stderr,"getfile: getting %s\n\n",doc->address);
}
/*
* Protect against denial of service attacks
* via the port 19 CHARGEN service, and block
- * connections to the port 25 ESMTP service. - FM
+ * connections to the port 25 ESMTP service.
+ * Also reject any likely spoof attempts via
+ * wrap arounds at 65536. - FM
*/
if ((temp = HTParse(doc->address, "", PARSE_HOST)) != NULL &&
strlen(temp) > 3) {
@@ -146,21 +149,27 @@ Try_Redirected_URL:
cp++;
if (sscanf(cp, "%ld", &value) == 1) {
- if (value > 65535 || value < 0) {
- HTAlert(PORT_INVALID);
- FREE(temp);
- return(NULLFILE);
- }
- if (value == 19) {
+ if (value == 19 || value == 65555) {
HTAlert(PORT_NINETEEN_INVALID);
FREE(temp);
return(NULLFILE);
}
- if (value == 25) {
+ if (value == 25 || value == 65561) {
HTAlert(PORT_TWENTYFIVE_INVALID);
FREE(temp);
return(NULLFILE);
}
+ if (value > 65535 || value < 0) {
+ char msg[265];
+ sprintf(msg, PORT_INVALID, (unsigned long)value);
+ HTAlert(msg);
+ FREE(temp);
+ return(NULLFILE);
+ }
+ } else if (isdigit((unsigned char)*cp)) {
+ HTAlert(URL_PORT_BAD);
+ FREE(temp);
+ return(NULLFILE);
}
}
}
@@ -591,7 +600,7 @@ Try_Redirected_URL:
StrAllocCopy(tmp, "http://");
if (TRACE)
fprintf(stderr,
- "LYGetFile: URL %s\n",
+ "getfile: URL '%s'\n",
doc->address);
*cp = '\0';
StrAllocCat(tmp, doc->address+9);
@@ -606,7 +615,7 @@ Try_Redirected_URL:
StrAllocCat(tmp, cp+8);
StrAllocCopy(doc->address, tmp);
if (TRACE)
- fprintf(stderr, " changed to %s\n",
+ fprintf(stderr, " changed to '%s'\n",
doc->address);
FREE(tmp);
url_type = HTTP_URL_TYPE;
@@ -639,7 +648,7 @@ Try_Redirected_URL:
char *cp2;
if (TRACE)
- fprintf(stderr, "LYGetFile: URL %s\n",
+ fprintf(stderr, "getfile: URL '%s'\n",
doc->address);
*cp1 = '\0';
cp1 += 2;
@@ -661,7 +670,7 @@ Try_Redirected_URL:
StrAllocCopy(doc->address, temp);
FREE(temp);
if (TRACE)
- fprintf(stderr, " changed to %s\n",
+ fprintf(stderr, " changed to '%s'\n",
doc->address);
WWWDoc.address = doc->address;
}
@@ -863,6 +872,15 @@ Try_Redirected_URL:
} else {
StrAllocCopy(fname, doc->address);
}
+ /*
+ * Check whether this is a compressed file,
+ * which we don't uncompress for downloads,
+ * and adjust any suffix appropriately. - FM
+ */
+ if (tmpanchor != NULL) {
+ HTCheckFnameForCompression(&fname, tmpanchor,
+ FALSE);
+ }
if (LYdownload_options(&fname,
WWW_Download_File) < 0) {
FREE(fname);
@@ -1295,10 +1313,10 @@ PRIVATE int fix_http_urls ARGS1(
* If we get to here, trim the trailing slash. - FM
*/
if (TRACE)
- fprintf(stderr,"LYGetFile: URL %s\n", doc->address);
+ fprintf(stderr, "fix_http_urls: URL '%s'\n", doc->address);
doc->address[strlen(doc->address)-1] = '\0';
if (TRACE) {
- fprintf(stderr," changed to %s\n", doc->address);
+ fprintf(stderr, " changed to '%s'\n", doc->address);
sleep(MessageSecs);
}
}
@@ -1312,10 +1330,10 @@ PRIVATE int fix_http_urls ARGS1(
}
}
if (TRACE)
- fprintf(stderr,"LYGetFile: URL %s\n", doc->address);
+ fprintf(stderr, "fix_http_urls: URL '%s'\n", doc->address);
StrAllocCat(doc->address, "/");
if (TRACE) {
- fprintf(stderr," changed to %s\n",doc->address);
+ fprintf(stderr, " changed to '%s'\n",doc->address);
sleep(MessageSecs);
}
diff --git a/src/LYLocal.c b/src/LYLocal.c
index 1524d84f..df518553 100644
--- a/src/LYLocal.c
+++ b/src/LYLocal.c
@@ -44,9 +44,11 @@
#include "LYSystem.h"
#ifndef VMS
+#ifndef _WINDOWS
#include <sys/wait.h>
#include <errno.h>
#include <grp.h>
+#endif /*_WINDOWS */
#endif /* VMS */
#include "LYLeaks.h"
@@ -2192,7 +2194,7 @@ PUBLIC int LYExecv ARGS3(
char **, argv,
char *, msg)
{
-#ifdef VMS
+#if defined(VMS) || defined(_WINDOWS)
if (TRACE) {
fprintf(stderr, "LYExecv: Called inappropriately!\n");
}
diff --git a/src/LYMain.c b/src/LYMain.c
index 89db134d..8b1c838a 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1192,6 +1192,10 @@ PUBLIC int main ARGS2(
/*
* Process the configuration file.
*/
+ if (TRACE) {
+ fprintf(stderr,
+ "Loading cfg file '%s'.\n", lynx_cfg_file);
+ }
read_cfg(lynx_cfg_file);
FREE(lynx_cfg_file);
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index 154930e6..40b113e3 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -156,6 +156,7 @@ int mainloop NOARGS
BOOLEAN LYRawMode_flag = LYRawMode;
BOOLEAN LYSelectPopups_flag = LYSelectPopups;
BOOLEAN trace_mode_flag = FALSE;
+ BOOLEAN forced_HTML_mode = LYforce_HTML_mode;
char cfile[128];
FILE *cfp;
char *cp, *toolbar;
@@ -963,6 +964,11 @@ try_again:
*/
first_file = FALSE;
+ /*
+ * Set the startrealm, and deal as best we can
+ * with preserving forced HTML mode for a local
+ * startfile. - FM
+ */
temp = HTParse(curdoc.address, "",
PARSE_ACCESS+PARSE_HOST+PARSE_PUNCTUATION);
if (!temp || *temp == '\0') {
@@ -976,6 +982,30 @@ try_again:
StrAllocCat(startrealm, "/");
}
} else {
+ if (forced_HTML_mode &&
+ !dump_output_immediately &&
+ !curdoc.bookmark &&
+ !strncasecomp(curdoc.address, "file:", 5) &&
+ strlen(temp) > 1) {
+ /*
+ * We forced HTML for a local startfile which
+ * is not a bookmark file and has a path of at
+ * least two letters. It it doesn't have a
+ * suffix mapped to text/html, we'll set the
+ * entire path (including the lead slash) as a
+ * "suffix" mapped to text/html to ensure it is
+ * always treated as an HTML source file. We
+ * are counting on a tail match to this full path
+ * for some other URL fetched during the session
+ * having too low a probability to worry about,
+ * but it could happen. - FM
+ */
+ HTAtom *encoding;
+
+ if (HTFileFormat(temp, &encoding) != WWW_HTML) {
+ HTSetSuffix(temp, "text/html", "8bit", 1.0);
+ }
+ }
if ((cp = strrchr(temp, '/')) != NULL) {
*(cp+1) = '\0';
StrAllocCat(startrealm, temp);
@@ -2520,6 +2550,8 @@ new_cmd: /*
!strncmp(curdoc.address, "file:", 5)) {
LYNoRefererForThis = TRUE;
}
+ StrAllocCopy(newdoc.title,
+ links[curdoc.link].hightext);
}
c = change_form_link(&links[curdoc.link],
FORM_UP, &newdoc, &refresh_screen,
@@ -4641,6 +4673,10 @@ check_add_bookmark_to_self:
(links[curdoc.link].type != WWW_FORM_LINK_TYPE ||
links[curdoc.link].form->type == F_SUBMIT_TYPE ||
links[curdoc.link].form->type == F_IMAGE_SUBMIT_TYPE)) {
+ /*
+ * We have links, and the current link is a
+ * normal link or a form's submit button. - FM
+ */
_statusline(HEAD_D_L_OR_CANCEL);
c = LYgetch();
if (TOUPPER(c) == 'D') {
@@ -4662,6 +4698,7 @@ check_add_bookmark_to_self:
}
HEAD_request = TRUE;
LYforce_no_cache = TRUE;
+ StrAllocCopy(newdoc.title, curdoc.title);
if (HTLoadedDocumentIsHEAD()) {
HTuncache_current_document();
FREE(curdoc.address);
@@ -4688,14 +4725,16 @@ check_add_bookmark_to_self:
_statusline(FORM_ACTION_NOT_HTTP_URL);
sleep(MessageSecs);
} else if (links[curdoc.link].type == WWW_FORM_LINK_TYPE &&
- links[curdoc.link].form->submit_method == URL_POST_METHOD &&
+ links[curdoc.link].form->submit_method ==
+ URL_POST_METHOD &&
HTConfirm(CONFIRM_POST_LINK_HEAD) == FALSE) {
_statusline(CANCELLED);
sleep(InfoSecs);
} else {
HEAD_request = TRUE;
LYforce_no_cache = TRUE;
- StrAllocCat(newdoc.title, " - HEAD");
+ StrAllocCopy(newdoc.title, links[curdoc.link].hightext);
+ StrAllocCat(newdoc.title, " - (HEAD)");
cmd = LYK_ACTIVATE;
goto new_cmd;
}
@@ -4704,6 +4743,7 @@ check_add_bookmark_to_self:
break;
} else {
/*
+ * We can offer only this document for a HEAD request.
* Check if this is a reply from a POST, and if so,
* seek confirmation if the safe element is not set. - FM
*/
@@ -4714,18 +4754,35 @@ check_add_bookmark_to_self:
sleep(InfoSecs);
break;
} else if (nlinks > 0) {
+ /*
+ * The current link is a non-submittable form
+ * link, so prompt the user to make it clear
+ * that the HEAD request would be for the
+ * current document, not the form link. - FM
+ */
_statusline(HEAD_D_OR_CANCEL);
c = LYgetch();
} else {
+ /*
+ * No links, so we can just assume that
+ * the user wants a HEAD request for the
+ * current document. - FM
+ */
c = 'D';
}
if (TOUPPER(c) == 'D') {
+ /*
+ * The user didn't cancel, so check if
+ * a HEAD request is appropriate for the
+ * current document. - FM
+ */
if (strncmp(curdoc.address, "http", 4)) {
_statusline(DOC_NOT_HTTP_URL);
sleep(MessageSecs);
} else {
HEAD_request = TRUE;
LYforce_no_cache = TRUE;
+ StrAllocCopy(newdoc.title, curdoc.title);
if (HTLoadedDocumentIsHEAD()) {
HTuncache_current_document();
FREE(curdoc.address);
@@ -4738,7 +4795,7 @@ check_add_bookmark_to_self:
break;
case LYK_TOGGLE_HELP:
- if (user_mode==NOVICE_MODE) {
+ if (user_mode == NOVICE_MODE) {
toggle_novice_line();
noviceline(more);
}
diff --git a/src/LYOptions.c b/src/LYOptions.c
index 59ba4822..c4ef236c 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -2133,6 +2133,9 @@ PRIVATE int popup_choice ARGS6(
return(orig_choice);
}
scrollok(form_window, TRUE);
+#ifdef PDCURSES
+ keypad(form_window, TRUE);
+#endif /* PDCURSES */
#ifdef NCURSES
#ifdef wgetbkgd
#define getbkgd(w) wgetbkgd(w) /* workaround pre-1.9.9g bug */
diff --git a/src/LYShowInfo.c b/src/LYShowInfo.c
index 156e4baf..2cd1b05b 100644
--- a/src/LYShowInfo.c
+++ b/src/LYShowInfo.c
@@ -240,7 +240,8 @@ PUBLIC int showinfo ARGS4(
StrAllocCopy(Title, doc->title);
LYEntify(&Title, TRUE);
- fprintf(fp0,"<dt><em>Linkname:</em> %s\n", Title);
+ fprintf(fp0, "<dt><em>Linkname:</em> %s%s\n",
+ Title, (doc->isHEAD ? " (HEAD)" : ""));
StrAllocCopy(Address, doc->address);
LYEntify(&Address, TRUE);
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 8073ac04..ba4d706d 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -191,7 +191,12 @@ PUBLIC void highlight ARGS3(
if (links[cur].hightext2 && links[cur].ly < display_lines) {
lynx_stop_link_color (flag == ON, links[cur].inUnderline);
- addch('\n');
+#ifndef USE_SLANG
+ if ((char)(inch() & A_CHARTEXT) == '-')
+ move(links[cur].ly + 1, 0);
+ else
+#endif
+ addch('\n');
for (i = 0; i < links[cur].hightext2_offset; i++)
addch(' ');
@@ -660,8 +665,8 @@ highlight_hit_within_hightext:
/*
* Start emphasis immediately if we are making
* the link non-current, or we are making it
- * current but this is not the first character
- * of the hightext. - FM
+ * current but this is not the first or last
+ * character of the hightext. - FM
*/
if (flag != ON ||
(offset > hoffset && data[itmp+1] != '\0')) {
@@ -1329,10 +1334,11 @@ highlight_hit_within_hightext2:
/*
* Start emphasis immediately if we are making
* the link non-current, or we are making it
- * current but this is not the first character
- * of the hightext2. - FM
+ * current but this is not the first or last
+ * character of the hightext2. - FM
*/
- if (flag != ON || offset > hoffset) {
+ if (flag != ON ||
+ (offset > hoffset && data[itmp+1] != '\0')) {
LYstartTargetEmphasis();
TargetEmphasisON = TRUE;
addstr(tmp);
@@ -1350,10 +1356,11 @@ highlight_hit_within_hightext2:
/*
* Start emphasis immediately if we are making
* the link non-current, or we are making it
- * current but this is not the first character
- * of the hightext2. - FM
+ * current but this is not the first or last
+ * character of the hightext2. - FM
*/
- if (flag != ON || offset > hoffset) {
+ if (flag != ON ||
+ (offset > hoffset && data[itmp+1] != '\0')) {
LYstartTargetEmphasis();
TargetEmphasisON = TRUE;
addstr(tmp);
@@ -1366,10 +1373,11 @@ highlight_hit_within_hightext2:
/*
* Start emphasis immediately if we are making
* the link non-current, or we are making it
- * current but this is not the first character
- * of the hightext2. - FM
+ * current but this is not the first or last
+ * character of the hightext2. - FM
*/
- if (flag != ON || offset > hoffset) {
+ if (flag != ON ||
+ (offset > hoffset && data[itmp+1] != '\0')) {
LYstartTargetEmphasis();
TargetEmphasisON = TRUE;
addstr(tmp);
@@ -4182,29 +4190,61 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
fprintf(stdout, "Looking up '%s' first.\n", host);
}
#ifndef DJGPP
- if ((phost = gethostbyname(host)) != NULL) {
+ if ((phost = gethostbyname(host)) != NULL)
#else
- if (resolve(host) != 0) {
+ if (resolve(host) != 0)
#endif /* DJGPP */
+ {
+ /*
+ * Clear any residual interrupt. - FM
+ */
+ if (LYCursesON && HTCheckForInterrupt()) {
+ if (TRACE) {
+ fprintf(stderr,
+ "LYExpandHostForURL: Ignoring interrupt because '%s' resolved.\n",
+ host);
+ }
+ }
+
+ /*
+ * Return success. - FM
+ */
GotHost = TRUE;
FREE(host);
FREE(Str);
FREE(MsgStr);
return GotHost;
+ } else if (LYCursesON && HTCheckForInterrupt()) {
+ /*
+ * Give the user chance to interrupt lookup cycles. - KW & FM
+ */
+ if (TRACE) {
+ fprintf(stderr,
+ "LYExpandHostForURL: Interrupted while '%s' failed to resolve.\n",
+ host);
+ }
+
+ /*
+ * Return failure. - FM
+ */
+ FREE(host);
+ FREE(Str);
+ FREE(MsgStr);
+ return FALSE;
}
/*
- ** Set the first prefix, making it a zero-length string
- ** if the list is NULL or if the potential host field
- ** ends with a dot. - FM
- */
+ * Set the first prefix, making it a zero-length string
+ * if the list is NULL or if the potential host field
+ * ends with a dot. - FM
+ */
StartP = ((prefix_list && Str[strlen(Str)-1] != '.') ?
prefix_list : "");
/*
- ** If we have a prefix, but the allocated string is
- ** one of the common host prefixes, make our prefix
- ** a zero-length string. - FM
- */
+ * If we have a prefix, but the allocated string is
+ * one of the common host prefixes, make our prefix
+ * a zero-length string. - FM
+ */
if (*StartP && *StartP != '.') {
if (!strncasecomp(*AllocatedString, "www.", 4) ||
!strncasecomp(*AllocatedString, "ftp.", 4) ||
@@ -4229,14 +4269,14 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
LYstrncpy(DomainPrefix, StartP, (EndP - StartP));
/*
- ** Test each prefix with each suffix. - FM
- */
+ * Test each prefix with each suffix. - FM
+ */
do {
/*
- ** Set the first suffix, making it a zero-length string
- ** if the list is NULL or if the potential host field
- ** begins with a dot. - FM
- */
+ * Set the first suffix, making it a zero-length string
+ * if the list is NULL or if the potential host field
+ * begins with a dot. - FM
+ */
StartS = ((suffix_list && *Str != '.') ?
suffix_list : "");
while ((*StartS) && (WHITE(*StartS) || *StartS == ',')) {
@@ -4249,8 +4289,8 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
LYstrncpy(DomainSuffix, StartS, (EndS - StartS));
/*
- ** Create domain names and do DNS tests. - FM
- */
+ * Create domain names and do DNS tests. - FM
+ */
do {
StrAllocCopy(Host, DomainPrefix);
StrAllocCat(Host, ((*Str == '.') ? (Str + 1) : Str));
@@ -4287,7 +4327,7 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
if (LYCursesON && HTCheckForInterrupt()) {
if (TRACE) {
fprintf(stderr,
- "*** LYExpandHostForURL interrupted while %s failed to resolve\n",
+ "LYExpandHostForURL: Interrupted while '%s' failed to resolve.\n",
host);
}
FREE(Str);
@@ -4298,8 +4338,8 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
}
/*
- ** Advance to the next suffix, or end of suffix list. - FM
- */
+ * Advance to the next suffix, or end of suffix list. - FM
+ */
StartS = ((*EndS == '\0') ? EndS : (EndS + 1));
while ((*StartS) && (WHITE(*StartS) || *StartS == ',')) {
StartS++; /* Skip whitespace and separators */
@@ -4314,8 +4354,8 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
if (GotHost == FALSE) {
/*
- ** Advance to the next prefix, or end of prefix list. - FM
- */
+ * Advance to the next prefix, or end of prefix list. - FM
+ */
StartP = ((*EndP == '\0') ? EndP : (EndP + 1));
while ((*StartP) && (WHITE(*StartP) || *StartP == ',')) {
StartP++; /* Skip whitespace and separators */
@@ -4351,6 +4391,18 @@ PUBLIC BOOLEAN LYExpandHostForURL ARGS3(
}
/*
+ * Clear any residual interrupt. - FM
+ */
+ if (LYCursesON && HTCheckForInterrupt()) {
+ if (TRACE) {
+ fprintf(stderr,
+ "LYExpandHostForURL: Ignoring interrupt because '%s' %s.\n",
+ host,
+ (GotHost ? "resolved" : "timed out"));
+ }
+ }
+
+ /*
* Clean up and return the last test result. - FM
*/
FREE(Str);
diff --git a/src/Makefile b/src/Makefile
index 5c8048cc..30ad4f31 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -69,6 +69,7 @@ TABLES= $(CHRTR)iso02_uni.h \
$(CHRTR)cp437_uni.h \
$(CHRTR)cp850_uni.h \
$(CHRTR)cp852_uni.h \
+ $(CHRTR)cp866_uni.h \
$(CHRTR)cp1250_uni.h \
$(CHRTR)cp1251_uni.h \
$(CHRTR)cp1252_uni.h \
diff --git a/src/UCAux.c b/src/UCAux.c
index e6d9247f..3eb5fcfe 100644
--- a/src/UCAux.c
+++ b/src/UCAux.c
@@ -69,12 +69,13 @@ PUBLIC BOOL UCCanTranslateFromTo ARGS2(
if (!strcmp(fromname, "koi8-r") || /* from cyrillic */
!strcmp(fromname, "iso-8859-5") ||
+ !strcmp(fromname, "cp866") ||
!strcmp(fromname, "windows-1251") ||
!strcmp(fromname, "koi-8")) {
if (strcmp(toname, "iso-8859-5") &&
strcmp(toname, "koi8-r") &&
- strcmp(toname, "windows-1251") &&
- strcmp(toname, "iso-8859-2"))
+ strcmp(toname, "cp866") &&
+ strcmp(toname, "windows-1251"))
return NO;
}
}
diff --git a/src/UCdomap.c b/src/UCdomap.c
index c32044f2..288b52aa 100644
--- a/src/UCdomap.c
+++ b/src/UCdomap.c
@@ -46,6 +46,7 @@
#include "[.chrtrans]cp437_uni.h"
#include "[.chrtrans]cp850_uni.h"
#include "[.chrtrans]cp852_uni.h"
+#include "[.chrtrans]cp866_uni.h"
#include "[.chrtrans]cp1250_uni.h"
#include "[.chrtrans]cp1251_uni.h"
#include "[.chrtrans]cp1252_uni.h"
@@ -69,6 +70,7 @@
#include "chrtrans/cp437_uni.h"
#include "chrtrans/cp850_uni.h"
#include "chrtrans/cp852_uni.h"
+#include "chrtrans/cp866_uni.h"
#include "chrtrans/cp1250_uni.h"
#include "chrtrans/cp1251_uni.h"
#include "chrtrans/cp1252_uni.h"
@@ -1670,6 +1672,7 @@ PUBLIC void UCInit NOARGS
UC_CHARSET_SETUP_cp437;
UC_CHARSET_SETUP_cp850;
UC_CHARSET_SETUP_cp852;
+ UC_CHARSET_SETUP_cp866;
UC_CHARSET_SETUP_windows_1250;
UC_CHARSET_SETUP_windows_1251;
UC_CHARSET_SETUP_iso_8859_1_windows_;
diff --git a/src/chrtrans/MAKEW32.BAT b/src/chrtrans/MAKEW32.BAT
index 3655ba0f..0c17aa1d 100644
--- a/src/chrtrans/MAKEW32.BAT
+++ b/src/chrtrans/MAKEW32.BAT
@@ -7,13 +7,17 @@ makeuctb iso02_uni.tbl > iso02_uni.h
makeuctb iso03_uni.tbl > iso03_uni.h
makeuctb iso04_uni.tbl > iso04_uni.h
makeuctb iso05_uni.tbl > iso05_uni.h
+makeuctb iso06_uni.tbl > iso06_uni.h
makeuctb iso07_uni.tbl > iso07_uni.h
+makeuctb iso08_uni.tbl > iso08_uni.h
makeuctb iso09_uni.tbl > iso09_uni.h
makeuctb iso10_uni.tbl > iso10_uni.h
makeuctb cp437_uni.tbl > cp437_uni.h
+makeuctb cp866_uni.tbl > cp866_uni.h
makeuctb cp850_uni.tbl > cp850_uni.h
makeuctb cp852_uni.tbl > cp852_uni.h
makeuctb cp1250_uni.tbl > cp1250_uni.h
+makeuctb cp1251_uni.tbl > cp1251_uni.h
makeuctb cp1252_uni.tbl > cp1252_uni.h
makeuctb utf8_uni.tbl > utf8_uni.h
makeuctb mnemonic_suni.tbl > mnemonic_suni.h
diff --git a/src/chrtrans/Makefile b/src/chrtrans/Makefile
index af982a90..f5a44374 100644
--- a/src/chrtrans/Makefile
+++ b/src/chrtrans/Makefile
@@ -35,6 +35,7 @@ TABLES= $(CHRTR)iso02_uni.h \
$(CHRTR)cp437_uni.h \
$(CHRTR)cp850_uni.h \
$(CHRTR)cp852_uni.h \
+ $(CHRTR)cp866_uni.h \
$(CHRTR)cp1250_uni.h \
$(CHRTR)cp1251_uni.h \
$(CHRTR)cp1252_uni.h \
diff --git a/src/chrtrans/build-chrtrans.com b/src/chrtrans/build-chrtrans.com
index c2604a9f..f6f0609e 100644
--- a/src/chrtrans/build-chrtrans.com
+++ b/src/chrtrans/build-chrtrans.com
@@ -102,6 +102,8 @@ $ define/user sys$output 'CHRwhere'cp850_uni.h
$ makeuctb cp850_uni.tbl
$ define/user sys$output 'CHRwhere'cp852_uni.h
$ makeuctb cp852_uni.tbl
+$ define/user sys$output 'CHRwhere'cp866_uni.h
+$ makeuctb cp866_uni.tbl
$ define/user sys$output 'CHRwhere'cp1250_uni.h
$ makeuctb cp1250_uni.tbl
$ define/user sys$output 'CHRwhere'cp1251_uni.h
diff --git a/src/chrtrans/cp1251_uni.tbl b/src/chrtrans/cp1251_uni.tbl
index ada70396..21a44414 100644
--- a/src/chrtrans/cp1251_uni.tbl
+++ b/src/chrtrans/cp1251_uni.tbl
@@ -21,6 +21,7 @@ OWinCyrillic (cp1251)
#
# The entries are in cp1251_WinCyrillic order
#
+0x20-0x7f idem
0x80 U+0402 #CYRILLIC CAPITAL LETTER DJE
0x81 U+0403 #CYRILLIC CAPITAL LETTER GJE
0x82 U+201A #SINGLE LOW-9 QUOTATION MARK
diff --git a/src/chrtrans/cp866_uni.tbl b/src/chrtrans/cp866_uni.tbl
new file mode 100644
index 00000000..2b109897
--- /dev/null
+++ b/src/chrtrans/cp866_uni.tbl
@@ -0,0 +1,189 @@
+#
+#The MIME name of this charset.
+Mcp866
+
+#Name as a Display Charset (used on Options screen)
+ODosCyrillic (cp866)
+#
+# Name: cp866_DOSCyrillicRussian to Unicode table
+# Unicode version: 2.0
+# Table version: 2.00
+# Table format: Format A
+# Date: 04/24/96
+# Authors: Lori Brownell <loribr@microsoft.com>
+# K.D. Chang <a-kchang@microsoft.com>
+# General notes: none
+#
+# Format: Three tab-separated columns
+# Column #1 is the cp866_DOSCyrillicRussian code (in hex)
+# Column #2 is the Unicode (in hex as 0xXXXX)
+# Column #3 is the Unicode name (follows a comment sign, '#')
+#
+# The entries are in cp866_DOSCyrillicRussian order
+#
+0x20-0x40 idem
+
+# some mapppings of greek capital letters to latin letters added - kw
+0x41 U+0041 U+0391 #LATIN CAPITAL LETTER A
+0x42 U+0042 U+0392 #LATIN CAPITAL LETTER B
+0x43 U+0043 #LATIN CAPITAL LETTER C
+0x44 U+0044 #LATIN CAPITAL LETTER D
+0x45 U+0045 U+0395 #LATIN CAPITAL LETTER E
+0x46 U+0046 #LATIN CAPITAL LETTER F
+0x47 U+0047 #LATIN CAPITAL LETTER G
+0x48 U+0048 U+0397 #LATIN CAPITAL LETTER H
+0x49 U+0049 U+0399 #LATIN CAPITAL LETTER I
+0x4a U+004a #LATIN CAPITAL LETTER J
+0x4b U+004b U+039a #LATIN CAPITAL LETTER K
+0x4c U+004c #LATIN CAPITAL LETTER L
+0x4d U+004d U+039c #LATIN CAPITAL LETTER M
+0x4e U+004e U+039d #LATIN CAPITAL LETTER N
+0x4f U+004f U+039f #LATIN CAPITAL LETTER O
+0x50 U+0050 U+03a1 #LATIN CAPITAL LETTER P
+0x51 U+0051 #LATIN CAPITAL LETTER Q
+0x52 U+0052 #LATIN CAPITAL LETTER R
+0x53 U+0053 #LATIN CAPITAL LETTER S
+0x54 U+0054 U+03a4 #LATIN CAPITAL LETTER T
+0x55 U+0055 #LATIN CAPITAL LETTER U
+0x56 U+0056 #LATIN CAPITAL LETTER V
+0x57 U+0057 #LATIN CAPITAL LETTER W
+0x58 U+0058 U+03a7 #LATIN CAPITAL LETTER X
+0x59 U+0059 U+03a5 #LATIN CAPITAL LETTER Y
+0x5a U+005a U+0396 #LATIN CAPITAL LETTER Z
+0x5b-0x7f idem
+
+0x80 U+0410 #CYRILLIC CAPITAL LETTER A
+0x81 U+0411 #CYRILLIC CAPITAL LETTER BE
+0x82 U+0412 #CYRILLIC CAPITAL LETTER VE
+0x83 U+0413 #CYRILLIC CAPITAL LETTER GHE
+0x84 U+0414 #CYRILLIC CAPITAL LETTER DE
+0x85 U+0415 #CYRILLIC CAPITAL LETTER IE
+0x86 U+0416 #CYRILLIC CAPITAL LETTER ZHE
+0x87 U+0417 #CYRILLIC CAPITAL LETTER ZE
+0x88 U+0418 #CYRILLIC CAPITAL LETTER I
+0x89 U+0419 #CYRILLIC CAPITAL LETTER SHORT I
+0x8a U+041a #CYRILLIC CAPITAL LETTER KA
+0x8b U+041b #CYRILLIC CAPITAL LETTER EL
+0x8c U+041c #CYRILLIC CAPITAL LETTER EM
+0x8d U+041d #CYRILLIC CAPITAL LETTER EN
+0x8e U+041e #CYRILLIC CAPITAL LETTER O
+0x8f U+041f #CYRILLIC CAPITAL LETTER PE
+0x90 U+0420 #CYRILLIC CAPITAL LETTER ER
+0x91 U+0421 #CYRILLIC CAPITAL LETTER ES
+0x92 U+0422 #CYRILLIC CAPITAL LETTER TE
+0x93 U+0423 #CYRILLIC CAPITAL LETTER U
+0x94 U+0424 #CYRILLIC CAPITAL LETTER EF
+0x95 U+0425 #CYRILLIC CAPITAL LETTER HA
+0x96 U+0426 #CYRILLIC CAPITAL LETTER TSE
+0x97 U+0427 #CYRILLIC CAPITAL LETTER CHE
+0x98 U+0428 #CYRILLIC CAPITAL LETTER SHA
+0x99 U+0429 #CYRILLIC CAPITAL LETTER SHCHA
+0x9a U+042a #CYRILLIC CAPITAL LETTER HARD SIGN
+0x9b U+042b #CYRILLIC CAPITAL LETTER YERU
+0x9c U+042c #CYRILLIC CAPITAL LETTER SOFT SIGN
+0x9d U+042d #CYRILLIC CAPITAL LETTER E
+0x9e U+042e #CYRILLIC CAPITAL LETTER YU
+0x9f U+042f #CYRILLIC CAPITAL LETTER YA
+0xa0 U+0430 #CYRILLIC SMALL LETTER A
+0xa1 U+0431 #CYRILLIC SMALL LETTER BE
+0xa2 U+0432 #CYRILLIC SMALL LETTER VE
+0xa3 U+0433 #CYRILLIC SMALL LETTER GHE
+0xa4 U+0434 #CYRILLIC SMALL LETTER DE
+0xa5 U+0435 #CYRILLIC SMALL LETTER IE
+0xa6 U+0436 #CYRILLIC SMALL LETTER ZHE
+0xa7 U+0437 #CYRILLIC SMALL LETTER ZE
+0xa8 U+0438 #CYRILLIC SMALL LETTER I
+0xa9 U+0439 #CYRILLIC SMALL LETTER SHORT I
+0xaa U+043a #CYRILLIC SMALL LETTER KA
+0xab U+043b #CYRILLIC SMALL LETTER EL
+0xac U+043c #CYRILLIC SMALL LETTER EM
+0xad U+043d #CYRILLIC SMALL LETTER EN
+0xae U+043e #CYRILLIC SMALL LETTER O
+0xaf U+043f #CYRILLIC SMALL LETTER PE
+0xb0 U+2591 #LIGHT SHADE
+0xb1 U+2592 #MEDIUM SHADE
+0xb2 U+2593 #DARK SHADE
+0xb3 U+2502 #BOX DRAWINGS LIGHT VERTICAL
+0xb4 U+2524 #BOX DRAWINGS LIGHT VERTICAL AND LEFT
+0xb5 U+2561 #BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+0xb6 U+2562 #BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+0xb7 U+2556 #BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+0xb8 U+2555 #BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+0xb9 U+2563 #BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+0xba U+2551 #BOX DRAWINGS DOUBLE VERTICAL
+0xbb U+2557 #BOX DRAWINGS DOUBLE DOWN AND LEFT
+0xbc U+255d #BOX DRAWINGS DOUBLE UP AND LEFT
+0xbd U+255c #BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+0xbe U+255b #BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+0xbf U+2510 #BOX DRAWINGS LIGHT DOWN AND LEFT
+0xc0 U+2514 #BOX DRAWINGS LIGHT UP AND RIGHT
+0xc1 U+2534 #BOX DRAWINGS LIGHT UP AND HORIZONTAL
+0xc2 U+252c #BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+0xc3 U+251c #BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+0xc4 U+2500 #BOX DRAWINGS LIGHT HORIZONTAL
+0xc5 U+253c #BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+0xc6 U+255e #BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+0xc7 U+255f #BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+0xc8 U+255a #BOX DRAWINGS DOUBLE UP AND RIGHT
+0xc9 U+2554 #BOX DRAWINGS DOUBLE DOWN AND RIGHT
+0xca U+2569 #BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+0xcb U+2566 #BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+0xcc U+2560 #BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+0xcd U+2550 #BOX DRAWINGS DOUBLE HORIZONTAL
+0xce U+256c #BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+0xcf U+2567 #BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+0xd0 U+2568 #BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+0xd1 U+2564 #BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+0xd2 U+2565 #BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+0xd3 U+2559 #BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+0xd4 U+2558 #BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+0xd5 U+2552 #BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+0xd6 U+2553 #BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+0xd7 U+256b #BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+0xd8 U+256a #BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+0xd9 U+2518 #BOX DRAWINGS LIGHT UP AND LEFT
+0xda U+250c #BOX DRAWINGS LIGHT DOWN AND RIGHT
+0xdb U+2588 #FULL BLOCK
+0xdc U+2584 #LOWER HALF BLOCK
+0xdd U+258c #LEFT HALF BLOCK
+0xde U+2590 #RIGHT HALF BLOCK
+0xdf U+2580 #UPPER HALF BLOCK
+0xe0 U+0440 #CYRILLIC SMALL LETTER ER
+0xe1 U+0441 #CYRILLIC SMALL LETTER ES
+0xe2 U+0442 #CYRILLIC SMALL LETTER TE
+0xe3 U+0443 #CYRILLIC SMALL LETTER U
+0xe4 U+0444 #CYRILLIC SMALL LETTER EF
+0xe5 U+0445 #CYRILLIC SMALL LETTER HA
+0xe6 U+0446 #CYRILLIC SMALL LETTER TSE
+0xe7 U+0447 #CYRILLIC SMALL LETTER CHE
+0xe8 U+0448 #CYRILLIC SMALL LETTER SHA
+0xe9 U+0449 #CYRILLIC SMALL LETTER SHCHA
+0xea U+044a #CYRILLIC SMALL LETTER HARD SIGN
+0xeb U+044b #CYRILLIC SMALL LETTER YERU
+0xec U+044c #CYRILLIC SMALL LETTER SOFT SIGN
+0xed U+044d #CYRILLIC SMALL LETTER E
+0xee U+044e #CYRILLIC SMALL LETTER YU
+0xef U+044f #CYRILLIC SMALL LETTER YA
+0xf0 U+0401 #CYRILLIC CAPITAL LETTER IO
+0xf1 U+0451 #CYRILLIC SMALL LETTER IO
+0xf2 U+0404 #CYRILLIC CAPITAL LETTER UKRAINIAN IE
+0xf3 U+0454 #CYRILLIC SMALL LETTER UKRAINIAN IE
+0xf4 U+0407 #CYRILLIC CAPITAL LETTER YI
+0xf5 U+0457 #CYRILLIC SMALL LETTER YI
+0xf6 U+040e #CYRILLIC CAPITAL LETTER SHORT U
+0xf7 U+045e #CYRILLIC SMALL LETTER SHORT U
+0xf8 U+00b0 #DEGREE SIGN
+0xf9 U+2219 #BULLET OPERATOR
+0xfa U+00b7 #MIDDLE DOT
+0xfb U+221a #SQUARE ROOT
+0xfc U+2116 #NUMERO SIGN
+0xfd U+00a4 #CURRENCY SIGN
+0xfe U+25a0 #BLACK SQUARE
+0xff U+00a0 #NO-BREAK SPACE
+
+# TRADE MARK SIGN:
+U+2122:(TM)
+
+0x60 U+2018 # left single quotation mark <`>
+0x27 U+2019-U+201b # various single quotation marks <'>
+0x22 U+201c-U+201f # various double quotation marks <">
diff --git a/src/chrtrans/koi8r_uni.tbl b/src/chrtrans/koi8r_uni.tbl
index 99b5e28d..c4946a50 100644
--- a/src/chrtrans/koi8r_uni.tbl
+++ b/src/chrtrans/koi8r_uni.tbl
@@ -1,11 +1,10 @@
-
-
# Options screen name for this character set
-O KOI8-R character set
+OKOI8-R character set
# MIME name for this charset
-M koi8-r
+Mkoi8-r
+0x20-0x7f idem
# Based on a table received from "Glenn E. Thobe" <thobe@lafn.org>
#hex unicode # description
#--- U+---- # ---------------
@@ -137,3 +136,10 @@ M koi8-r
0xFD U+0429 # CAP SHCHA
0xFE U+0427 # CAP CHE
0xFF U+042A # CAP HARD SIGN
+
+# TRADE MARK SIGN:
+U+2122:(TM)
+
+0x60 U+2018 # left single quotation mark <`>
+0x27 U+2019-U+201b # various single quotation marks <'>
+0x22 U+201c-U+201f # various double quotation marks <">
diff --git a/src/chrtrans/makefile.in b/src/chrtrans/makefile.in
index e293d1ad..b1e00c7d 100644
--- a/src/chrtrans/makefile.in
+++ b/src/chrtrans/makefile.in
@@ -47,6 +47,7 @@ TABLES= $(CHRTR)iso02_uni.h \
$(CHRTR)cp437_uni.h \
$(CHRTR)cp850_uni.h \
$(CHRTR)cp852_uni.h \
+ $(CHRTR)cp866_uni.h \
$(CHRTR)cp1250_uni.h \
$(CHRTR)cp1251_uni.h \
$(CHRTR)cp1252_uni.h \
diff --git a/src/makefile.in b/src/makefile.in
index 773fb6bf..e024ff12 100644
--- a/src/makefile.in
+++ b/src/makefile.in
@@ -101,6 +101,7 @@ TABLES= $(CHRTR)iso02_uni.h \
$(CHRTR)cp437_uni.h \
$(CHRTR)cp850_uni.h \
$(CHRTR)cp852_uni.h \
+ $(CHRTR)cp866_uni.h \
$(CHRTR)cp1250_uni.h \
$(CHRTR)cp1251_uni.h \
$(CHRTR)cp1252_uni.h \