aboutsummaryrefslogtreecommitdiffstats
path: root/WWW/Library/Implementation
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r--WWW/Library/Implementation/HTAAProt.c42
-rw-r--r--WWW/Library/Implementation/HTAnchor.c5
-rw-r--r--WWW/Library/Implementation/HTFile.c70
-rw-r--r--WWW/Library/Implementation/HTParse.c30
-rw-r--r--WWW/Library/Implementation/HTParse.h9
-rw-r--r--WWW/Library/Implementation/HTRules.c9
-rw-r--r--WWW/Library/Implementation/HTRules.h5
-rw-r--r--WWW/Library/Implementation/HTString.c51
-rw-r--r--WWW/Library/Implementation/HTTCP.c77
-rw-r--r--WWW/Library/Implementation/HTTCP.h1
-rw-r--r--WWW/Library/Implementation/HTTP.c20
-rw-r--r--WWW/Library/Implementation/HTTelnet.c14
-rw-r--r--WWW/Library/Implementation/HTUtils.h14
-rw-r--r--WWW/Library/Implementation/LYexit.h2
-rw-r--r--WWW/Library/Implementation/tcp.h2
15 files changed, 280 insertions, 71 deletions
diff --git a/WWW/Library/Implementation/HTAAProt.c b/WWW/Library/Implementation/HTAAProt.c
index a7915121..8157ed56 100644
--- a/WWW/Library/Implementation/HTAAProt.c
+++ b/WWW/Library/Implementation/HTAAProt.c
@@ -575,14 +575,41 @@ typedef struct {
int user;
} USER_DATA;
-PRIVATE HTList *known_grp;
-PRIVATE HTList *known_pwd;
+PRIVATE HTList *known_grp = NULL;
+PRIVATE HTList *known_pwd = NULL;
+PRIVATE BOOL uidgid_cache_inited = NO;
+
+PRIVATE void clear_uidgid_cache NOARGS
+{
+ USER_DATA *data;
+ if (known_grp) {
+ while ((data = HTList_removeLastObject(known_grp)) != NULL) {
+ FREE(data->name);
+ FREE(data);
+ }
+ FREE(known_grp);
+ }
+ if (known_pwd) {
+ while ((data = HTList_removeLastObject(known_pwd)) != NULL) {
+ FREE(data->name);
+ FREE(data);
+ }
+ FREE(known_pwd);
+ }
+}
PRIVATE void save_gid_info ARGS2(char *, name, int, user)
{
USER_DATA *data = calloc(1, sizeof(USER_DATA));
- if (HTList_isEmpty(known_grp))
+ if (!data)
+ return;
+ if (!known_grp) {
known_grp = HTList_new();
+ if (!uidgid_cache_inited) {
+ atexit(clear_uidgid_cache);
+ uidgid_cache_inited = YES;
+ }
+ }
StrAllocCopy(data->name, name);
data->user = user;
HTList_addObject (known_grp, data);
@@ -591,8 +618,15 @@ PRIVATE void save_gid_info ARGS2(char *, name, int, user)
PRIVATE void save_uid_info ARGS2(char *, name, int, user)
{
USER_DATA *data = calloc(1, sizeof(USER_DATA));
- if (HTList_isEmpty(known_pwd))
+ if (!data)
+ return;
+ if (!known_pwd) {
known_pwd = HTList_new();
+ if (!uidgid_cache_inited) {
+ atexit(clear_uidgid_cache);
+ uidgid_cache_inited = YES;
+ }
+ }
StrAllocCopy(data->name, name);
data->user = user;
HTList_addObject (known_pwd, data);
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index 53ce0c78..74399c91 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -302,6 +302,11 @@ PRIVATE void free_adult_table NOARGS
adult_table[i_counter] = HTAp_freeme->next;
if (HTAp_freeme->object) {
parent = (HTParentAnchor *)HTAp_freeme->object;
+ CTRACE(tfp, "delete anchor:%d/%d,%d,%d %s\n",
+ i_counter, HTList_count(HTAp_freeme) + 1,
+ (parent->physical ? 1 : 0),
+ (int)parent->underway,
+ (parent->address ? parent->address : "(no address)"));
parent->underway = FALSE;
HTAnchor_delete(parent);
}
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index c4826feb..1c419daa 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -17,7 +17,7 @@
** 15 Nov 93 (MD) Moved HTVMSname to HTVMSUTILS.C
** 27 Dec 93 (FM) FTP now works with VMS hosts.
** FTP path must be Unix-style and cannot include
-** the device or top directory.
+** the device or top directory.
*/
#include <HTUtils.h>
@@ -151,26 +151,35 @@ int exists(char *filename)
PRIVATE void free_suffixes NOPARAMS;
#ifdef LONG_LIST
-PRIVATE char *FormatStr ARGS2(
+PRIVATE char *FormatStr ARGS3(
+ char **, bufp,
char *, start,
char *, entry)
{
char fmt[512];
- char *buf = 0;
- sprintf(fmt, "%%%.*ss", (int) sizeof(fmt) - 3, start);
- HTSprintf0(&buf, fmt, entry);
- return buf;
+ if (*start) {
+ sprintf(fmt, "%%%.*ss", (int) sizeof(fmt) - 3, start);
+ HTSprintf0(bufp, fmt, entry);
+ } else {
+ HTSprintf0(bufp, "%s", entry);
+ }
+ return *bufp;
}
-PRIVATE char *FormatNum ARGS2(
+PRIVATE char *FormatNum ARGS3(
+ char **, bufp,
char *, start,
int, entry)
{
char fmt[512];
- char *buf = 0;
- sprintf(fmt, "%%%.*sd", (int) sizeof(fmt) - 3, start);
- HTSprintf0(&buf, fmt, entry);
- return buf;
+ if (*start) {
+ sprintf(fmt, "%%%.*sd", (int) sizeof(fmt) - 3, start);
+ HTSprintf0(bufp, fmt, entry);
+ } else {
+ sprintf(fmt, "%d", entry);
+ StrAllocCat(*bufp, fmt);
+ }
+ return *bufp;
}
PRIVATE void LYListFmtParse ARGS5(
@@ -205,7 +214,7 @@ PRIVATE void LYListFmtParse ARGS5(
"r-T", "r-t", "rwT", "rwt", 0 };
#define PTBIT(a, s) (s) ? ptbits[(a) & 0x7] : pbits[(a) & 0x7]
#else
-#define PTBIT(a, s) (a, 0, 0)
+#define PTBIT(a, s) PBIT(a, 0, 0)
#endif
if (lstat(file, &st) < 0)
@@ -234,19 +243,21 @@ PRIVATE void LYListFmtParse ARGS5(
if (s == end)
break;
start = ++s;
- while (isdigit(*s) || *s == '.' || *s == '-')
+ while (isdigit(*s) || *s == '.' || *s == '-' || *s == ' ' ||
+ *s == '#' || *s == '+' || *s == '\'')
s++;
c = *s; /* the format char. or \0 */
*s = '\0';
switch (c) {
case '\0':
- break;
+ PUTS(start);
+ continue;
case 'A':
case 'a': /* anchor */
HTDirEntry(target, tail, entry);
- buf = FormatStr(start, entry);
+ FormatStr(&buf, start, entry);
PUTS(buf);
END(HTML_A);
*buf = '\0';
@@ -274,21 +285,21 @@ PRIVATE void LYListFmtParse ARGS5(
*/
sprintf(tmp, "%.7s %.4s ", datestr + 4,
datestr + 20);
- buf = FormatStr(start, tmp);
+ FormatStr(&buf, start, tmp);
break;
case 's': /* size in bytes */
- buf = FormatNum(start, st.st_size);
+ FormatNum(&buf, start, st.st_size);
break;
case 'K': /* size in Kilobytes but not for directories */
if (S_ISDIR(st.st_mode)) {
- buf = FormatStr(start, "");
+ FormatStr(&buf, start, "");
break;
}
/* FALL THROUGH */
case 'k': /* size in Kilobytes */
- buf = FormatNum(start, (st.st_size+1023)/1024);
+ FormatNum(&buf, start, (st.st_size+1023)/1024);
StrAllocCat(buf, "K");
break;
@@ -319,29 +330,33 @@ PRIVATE void LYListFmtParse ARGS5(
PBIT(st.st_mode, 6, st.st_mode & S_ISUID),
PBIT(st.st_mode, 3, st.st_mode & S_ISGID),
PTBIT(st.st_mode, st.st_mode & S_ISVTX));
- buf = FormatStr(start, tmp);
+ FormatStr(&buf, start, tmp);
break;
case 'o': /* owner */
name = HTAA_UidToName (st.st_uid);
if (*name) {
- buf = FormatStr(start, name);
+ FormatStr(&buf, start, name);
} else {
- buf = FormatNum(start, st.st_uid);
+ FormatNum(&buf, start, st.st_uid);
}
break;
case 'g': /* group */
name = HTAA_GidToName(st.st_gid);
if (*name) {
- buf = FormatStr(start, name);
+ FormatStr(&buf, start, name);
} else {
- buf = FormatNum(start, st.st_gid);
+ FormatNum(&buf, start, st.st_gid);
}
break;
case 'l': /* link count */
- buf = FormatNum(start, st.st_nlink);
+ FormatNum(&buf, start, st.st_nlink);
+ break;
+
+ case '%': /* literal % with flags/width */
+ FormatStr(&buf, start, "%");
break;
default:
@@ -349,11 +364,12 @@ PRIVATE void LYListFmtParse ARGS5(
"Unknown format character `%c' in list format\n", c);
break;
}
- PUTS(buf);
- FREE(buf);
+ if (buf)
+ PUTS(buf);
s++;
}
+ FREE(buf);
END(HTML_PRE);
PUTS("\n");
FREE(str);
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c
index d3805794..5f3f3f92 100644
--- a/WWW/Library/Implementation/HTParse.c
+++ b/WWW/Library/Implementation/HTParse.c
@@ -189,6 +189,13 @@ PUBLIC char * HTParse ARGS3(
CTRACE(tfp, "HTParse: aName:%s relatedName:%s\n", aName, relatedName);
+ if (wanted & (PARSE_STRICTPATH | PARSE_QUERY)) { /* if detail wanted... */
+ if ((wanted & (PARSE_STRICTPATH | PARSE_QUERY))
+ == (PARSE_STRICTPATH | PARSE_QUERY)) /* if strictpath AND query */
+ wanted |= PARSE_PATH; /* then treat as if PARSE_PATH wanted */
+ if (wanted & PARSE_PATH) /* if PARSE_PATH wanted */
+ wanted &= ~(PARSE_STRICTPATH | PARSE_QUERY); /* ignore details */
+ }
/*
** Allocate the output string.
*/
@@ -341,7 +348,11 @@ PUBLIC char * HTParse ARGS3(
/*
** Handle the path.
*/
- if (wanted & PARSE_PATH) {
+ if (wanted & (PARSE_PATH | PARSE_STRICTPATH | PARSE_QUERY)) {
+ char *tail = NULL;
+ int want_detail = (wanted & (PARSE_STRICTPATH | PARSE_QUERY));
+ if (want_detail)
+ tail = result + strlen(result);
if (acc_method && !given.absolute && given.relative) {
if (!strcasecomp(acc_method, "nntp") ||
!strcasecomp(acc_method, "snews") ||
@@ -391,6 +402,23 @@ PUBLIC char * HTParse ARGS3(
result[5] = '*';
CTRACE(tfp, "5\n");
}
+ if (want_detail) {
+ p = strchr(tail, '?'); /* Search part? */
+ if (p) {
+ if (PARSE_STRICTPATH) {
+ *p = '\0';
+ } else {
+ if (!(wanted & PARSE_PUNCTUATION))
+ p++;
+ do {
+ *tail++ = *p;
+ } while (*p++);
+ }
+ } else {
+ if (wanted & PARSE_QUERY)
+ *tail = '\0';
+ }
+ }
}
/*
diff --git a/WWW/Library/Implementation/HTParse.h b/WWW/Library/Implementation/HTParse.h
index 0307327d..2c27c238 100644
--- a/WWW/Library/Implementation/HTParse.h
+++ b/WWW/Library/Implementation/HTParse.h
@@ -20,6 +20,15 @@
#define PARSE_ANCHOR 2
#define PARSE_PUNCTUATION 1
#define PARSE_ALL 31
+/*
+** Additional flag bits for more details on components already
+** covered by the above. The PARSE_PATH above doesn't really
+** strictly refer to the path component in the sense of the URI
+** specs only, but rather to that combined with a possible query
+** component. - kw
+*/
+#define PARSE_STRICTPATH 32
+#define PARSE_QUERY 64
/*
** The following are valid mask values. The terms are the BNF names
diff --git a/WWW/Library/Implementation/HTRules.c b/WWW/Library/Implementation/HTRules.c
index d0ff1207..1dd5910d 100644
--- a/WWW/Library/Implementation/HTRules.c
+++ b/WWW/Library/Implementation/HTRules.c
@@ -100,6 +100,9 @@ PUBLIC int HTAddRule ARGS3(
CTRACE(tfp, "Rule: For `%s' op %d\n", pattern, op);
}
+ if (!rules) {
+ atexit(HTClearRules);
+ }
#ifdef PUT_ON_HEAD
temp->next = rules;
rules = temp;
@@ -120,12 +123,11 @@ PUBLIC int HTAddRule ARGS3(
**
** On exit,
** There are no rules
-** returns 0 if success, -1 if error.
**
** See also
** HTAddRule()
*/
-int HTClearRules NOARGS
+void HTClearRules NOARGS
{
while (rules) {
rule * temp = rules;
@@ -137,8 +139,6 @@ int HTClearRules NOARGS
#ifndef PUT_ON_HEAD
rule_tail = 0;
#endif
-
- return 0;
}
@@ -271,6 +271,7 @@ char * HTTranslate ARGS1(
case HT_Fail: /* Unauthorised */
CTRACE(tfp, "HTRule: *** FAIL `%s'\n",
current);
+ FREE(current);
return (char *)0;
} /* if tail matches ... switch operation */
diff --git a/WWW/Library/Implementation/HTRules.h b/WWW/Library/Implementation/HTRules.h
index d34c03ac..1eeccbb5 100644
--- a/WWW/Library/Implementation/HTRules.h
+++ b/WWW/Library/Implementation/HTRules.h
@@ -79,12 +79,9 @@ HTClearRules: Clear all rules
Rule file There are no rules
- returns
- 0 if success, -1 if error.
-
*/
-extern int HTClearRules PARAMS((void));
+extern void HTClearRules PARAMS((void));
/*
diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c
index fa037623..9a89afdf 100644
--- a/WWW/Library/Implementation/HTString.c
+++ b/WWW/Library/Implementation/HTString.c
@@ -368,6 +368,9 @@ typedef enum { Flags, Width, Prec, Type, Format } PRINTF;
#define VA_POINT(type) pval = (void *)va_arg((*ap), type)
#define NUM_WIDTH 10 /* allow for width substituted for "*" in "%*s" */
+ /* also number of chars assumed to be needed in addition
+ to a given precision in floating point formats */
+
#define GROW_EXPR(n) (((n) * 3) / 2)
#define GROW_SIZE 256
@@ -397,6 +400,7 @@ PRIVATE char * StrAllocVsprintf ARGS4(
dst_ptr = HTAlloc(dst_ptr, have = GROW_SIZE + need);
} else {
have = strlen(dst_ptr) + 1;
+ need += dst_len;
if (have < need)
dst_ptr = HTAlloc(dst_ptr, have = GROW_SIZE + need);
}
@@ -482,17 +486,13 @@ PRIVATE char * StrAllocVsprintf ARGS4(
break;
case 'c':
VA_INTGR(int);
- used = 'i';
+ used = 'c';
break;
case 's':
VA_POINT(char *);
if (prec < 0)
prec = strlen(pval);
- if (prec > (int)tmp_len) {
- tmp_len = GROW_EXPR(tmp_len + prec);
- tmp_ptr = HTAlloc(tmp_ptr, tmp_len);
- }
- used = 'p';
+ used = 's';
break;
case 'p':
VA_POINT(void *);
@@ -511,12 +511,36 @@ PRIVATE char * StrAllocVsprintf ARGS4(
state = Prec;
} else if (*fmt == '%') {
done = TRUE;
- used = 'p';
+ used = '%';
}
}
fmt_ptr[f] = '\0';
+
+ if (prec > 0) {
+ switch (used) {
+ case 'f':
+ if (width < prec + NUM_WIDTH)
+ width = prec + NUM_WIDTH;
+ case 'i':
+ case 'p':
+ if (width < prec + 2)
+ width = prec + 2; /* leading sign/space/zero, "0x" */
+ case 'c':
+ case '%':
+ break;
+ default:
+ if (width < prec)
+ width = prec;
+ }
+ }
+ if (width >= (int)tmp_len) {
+ tmp_len = GROW_EXPR(tmp_len + width);
+ tmp_ptr = HTAlloc(tmp_ptr, tmp_len);
+ }
+
switch (used) {
case 'i':
+ case 'c':
sprintf(tmp_ptr, fmt_ptr, ival);
break;
case 'f':
@@ -533,6 +557,9 @@ PRIVATE char * StrAllocVsprintf ARGS4(
strcpy(dst_ptr + dst_len, tmp_ptr);
dst_len += strlen(tmp_ptr);
} else {
+ if ((dst_len + 2) >= have) {
+ dst_ptr = HTAlloc(dst_ptr, (have += GROW_SIZE));
+ }
dst_ptr[dst_len++] = *fmt++;
}
}
@@ -597,8 +624,6 @@ PUBLIC char * HTSprintf0 (va_alist)
char ** pstr = va_arg(ap, char **);
CONST char * fmt = va_arg(ap, CONST char *);
#endif
- if (pstr != 0)
- *pstr = 0;
result = StrAllocVsprintf(pstr, 0, fmt, &ap);
}
va_end(ap);
@@ -710,16 +735,10 @@ PUBLIC void HTAddXpand ARGS4(
int, number,
CONST char *, parameter)
{
- if (*parameter != '$') {
- HTAddParam (result, command, number, parameter);
- } else if (number > 0) {
+ if (number > 0) {
CONST char *last = HTAfterCommandArg(command, number - 1);
CONST char *next = last;
- parameter = getenv(parameter+1);
- if (parameter == 0)
- parameter = "";
-
if (number <= 1) {
FREE(*result);
}
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index 1bc8f36f..d58b86d4 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -309,6 +309,52 @@ PUBLIC CONST char * HTInetString ARGS1(
}
#endif /* !DECNET */
+/* Check whether string is a valid Internet hostname - kw
+** -------------------------------------------------
+**
+** Checks whether
+** - contains only valid chars for domain names (actually, the
+** restrictions are somewhat relaxed),
+** - no leading dots or empty segments,
+** - max. length of dot-separated segment <= 63 (RFC 1034,1035),
+** - total length <= 254 (if it ends with dot) or 253 (otherwise)
+** [an interpretation of RFC 1034,1035, although RFC 1123
+** suggests 255 as limit - kw].
+**
+** Note: user (before '@') and port (after ':') components from
+** host part of URL should be already stripped (if appropriate)
+** from the input string.
+**
+** On exit,
+** returns 1 if valid, otherwise 0.
+*/
+PUBLIC BOOL valid_hostname ARGS1(
+ CONST char *, name)
+{
+ int i=1, iseg = 0;
+ CONST char *cp = name;
+ if (!(name && *name))
+ return NO;
+ for (; (*cp && i <= 253); cp++, i++) {
+ if (*cp == '.') {
+ if (iseg == 0) {
+ return NO;
+ } else {
+ iseg = 0;
+ continue;
+ }
+ } else if (++iseg > 63) {
+ return NO;
+ }
+ if (!isalnum((unsigned char)*cp) &&
+ *cp != '-' && *cp != '_' &&
+ *cp != '$' && *cp != '+') {
+ return NO;
+ }
+ }
+ return (*cp == '\0' || (*cp == '.' && iseg != 0 && cp[1] == '\0'));
+}
+
#ifdef NSL_FORK
/*
** Function to allow us to be killed with a normal signal (not
@@ -440,6 +486,13 @@ PUBLIC int HTParseInet ARGS2(
FREE(host);
#endif /* _WINDOWS_NSL */
} else { /* Alphanumeric node name: */
+ if (!valid_hostname(host)) {
+#ifndef _WINDOWS_NSL
+ FREE(host);
+#endif /* _WINDOWS_NSL */
+ return HT_NOT_ACCEPTABLE; /* only HTDoConnect checks this. */
+ }
+
#ifdef MVS /* Outstanding problem with crash in MVS gethostbyname */
CTRACE(tfp, "HTParseInet: Calling gethostbyname(%s)\n", host);
#endif /* MVS */
@@ -878,16 +931,22 @@ PUBLIC int HTDoConnect ARGS4(
}
FREE(p1);
- line = (char *)calloc(1, (strlen(host) + strlen(protocol) + 128));
- if (line == NULL)
- outofmem(__FILE__, "HTDoConnect");
- sprintf (line, gettext("Looking up %s."), host);
+ HTSprintf0 (&line, gettext("Looking up %s."), host);
_HTProgress (line);
status = HTParseInet(soc_in, host);
if (status) {
if (status != HT_INTERRUPTED) {
- sprintf (line, gettext("Unable to locate remote host %s."), host);
- _HTProgress(line);
+ if (status == HT_NOT_ACCEPTABLE) {
+ /* Not HTProgress, so warning won't be overwritten
+ * immediately; but not HTAlert, because typically
+ * there will be other alerts from the callers. - kw
+ */
+ HTUserMsg2(gettext("Invalid hostname %s"), host);
+ } else {
+ HTSprintf0 (&line,
+ gettext("Unable to locate remote host %s."), host);
+ _HTProgress(line);
+ }
status = HT_NO_DATA;
}
FREE(host);
@@ -895,9 +954,10 @@ PUBLIC int HTDoConnect ARGS4(
return status;
}
- sprintf (line, gettext("Making %s connection to %s."), protocol, host);
+ HTSprintf0 (&line, gettext("Making %s connection to %s."), protocol, host);
_HTProgress (line);
FREE(host);
+ FREE(line);
/*
** Now, let's get a socket set up from the server for the data.
@@ -905,7 +965,6 @@ PUBLIC int HTDoConnect ARGS4(
*s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (*s == -1) {
HTAlert(gettext("socket failed."));
- FREE(line);
return HT_NO_DATA;
}
@@ -979,7 +1038,6 @@ PUBLIC int HTDoConnect ARGS4(
*/
if (tries++ >= 180000) {
HTAlert(gettext("Connection failed for 180,000 tries."));
- FREE(line);
return HT_NO_DATA;
}
@@ -1118,7 +1176,6 @@ PUBLIC int HTDoConnect ARGS4(
#endif /* !NO_IOCTL || USE_FCNTL */
#endif /* !DOSPATH */
- FREE(line);
return status;
}
diff --git a/WWW/Library/Implementation/HTTCP.h b/WWW/Library/Implementation/HTTCP.h
index 89837fe7..63fe03aa 100644
--- a/WWW/Library/Implementation/HTTCP.h
+++ b/WWW/Library/Implementation/HTTCP.h
@@ -69,6 +69,7 @@ extern unsigned int HTCardinal PARAMS((int *pstatus,
char **pp,
unsigned int max_value));
+extern BOOL valid_hostname PARAMS((CONST char * name));
/* Parse an internet node address and port
** ---------------------------------------
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
index b7bf5ec7..37bb2052 100644
--- a/WWW/Library/Implementation/HTTP.c
+++ b/WWW/Library/Implementation/HTTP.c
@@ -305,14 +305,34 @@ try_again:
StrAllocCat(command, line);
}
+#if 0
/*
** Promote 300 (Multiple Choices) replies, if supported,
** over 406 (Not Acceptable) replies. - FM
+ **
+ ** This used to be done in versions 2.7 and 2.8*, but violates
+ ** the specs for transparent content negotiation and has the
+ ** effect that servers supporting those specs will send 300
+ ** (Multiple Choices) instead of a normal response (e.g. 200 OK),
+ ** since they will assume that the client wants to make the
+ ** choice. It is not clear whether there are any servers or sites
+ ** for which sending this header really improves anything.
+ **
+ ** If there ever is a need to send "Negotiate: trans" and really
+ ** mean it, we should send "Negotiate: trans,trans" or similar,
+ ** since that is semantically equivalent and some servers may
+ ** ignore "Negotiate: trans" as a special case when it comes from
+ ** Lynx (to work around the old faulty behavior). - kw
+ **
+ ** References:
+ ** RFC 2295 (see also RFC 2296), and mail to lynx-dev and
+ ** new-httpd@apache.org from Koen Holtman, Jan 1999.
*/
if (!do_post) {
sprintf(line, "Negotiate: trans%c%c", CR, LF);
StrAllocCat(command, line);
}
+#endif /* 0 */
/*
** When reloading give no-cache pragma to proxy server to make
diff --git a/WWW/Library/Implementation/HTTelnet.c b/WWW/Library/Implementation/HTTelnet.c
index 2b9039ab..e82a218b 100644
--- a/WWW/Library/Implementation/HTTelnet.c
+++ b/WWW/Library/Implementation/HTTelnet.c
@@ -25,6 +25,7 @@
#include <HTTP.h>
#include <HTFile.h>
+#include <HTTCP.h>
#include <HText.h>
#include <HTAccess.h>
@@ -88,6 +89,18 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
if (!hostname || *hostname == '\0') {
CTRACE(tfp, "HTTelnet: No host specified!\n");
return HT_NO_DATA;
+ } else if (!valid_hostname(hostname)) {
+ char *prefix = NULL;
+ char *line = NULL;
+ CTRACE(tfp, "HTTelnet: Invalid hostname %s!\n", host);
+ HTSprintf0(&prefix,
+ gettext("remote %s session:"), acc_method);
+ HTSprintf0(&line,
+ gettext("Invalid hostname %s"), host);
+ HTAlwaysAlert(prefix, line);
+ FREE(prefix);
+ FREE(line);
+ return HT_NO_DATA;
}
if (user) {
@@ -131,6 +144,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host)
printf("When you are connected, log in as: %s\n", user);
if (password && login_protocol != rlogin)
printf(" The password is: %s\n", password);
+ fflush(stdout);
/*
* NeXTSTEP is the implied version of the NeXT operating system.
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index 63843de3..18f6d661 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -311,10 +311,13 @@ extern BOOL LYOutOfMemory; /* Declared in LYexit.c - FM */
Sucess (>=0) and failure (<0) codes
+Some of the values are chosen to be HTTP-like, but status return values
+are generally not the response status from any specific protocol.
+
*/
-#define HT_REDIRECTING 29996
-#define HT_LOADED 29997 /* Instead of a socket */
+#define HT_REDIRECTING 399
+#define HT_LOADED 200 /* Instead of a socket */
#define HT_PARTIAL_CONTENT 206 /* Partial Content */
#define HT_INTERRUPTED -29998
#define HT_NOT_LOADED -29999
@@ -323,10 +326,13 @@ Sucess (>=0) and failure (<0) codes
#define HT_ERROR -1 /* Generic failure */
#define HT_CANNOT_TRANSLATE -4
-#define HT_NO_ACCESS -10 /* Access not available */
-#define HT_FORBIDDEN -11 /* Access forbidden */
+
#define HT_NO_DATA -204 /* OK but no data was loaded - */
/* possibly other app started or forked */
+#define HT_NO_ACCESS -401 /* Access not available */
+#define HT_FORBIDDEN -403 /* Access forbidden */
+#define HT_NOT_ACCEPTABLE -406 /* Not Acceptable */
+
#define HT_INTERNAL -900 /* Weird -- should never happen. */
#define HT_BAD_EOF -12 /* Premature EOF */
diff --git a/WWW/Library/Implementation/LYexit.h b/WWW/Library/Implementation/LYexit.h
index 62907a64..8e217776 100644
--- a/WWW/Library/Implementation/LYexit.h
+++ b/WWW/Library/Implementation/LYexit.h
@@ -30,7 +30,7 @@
#define exit LYexit
#define atexit LYatexit
-#define ATEXITSIZE 32
+#define ATEXITSIZE 40
/*
* Data structures
diff --git a/WWW/Library/Implementation/tcp.h b/WWW/Library/Implementation/tcp.h
index 8ecf282e..97f79d7b 100644
--- a/WWW/Library/Implementation/tcp.h
+++ b/WWW/Library/Implementation/tcp.h
@@ -497,8 +497,10 @@ struct timeval {
#undef NETCLOSE
#define NETCLOSE close_s
#define getsockname getsockname_s
+#ifdef HAVE_GETTEXT
#define gettext gettext__
#endif
+#endif /* DJGPP */
#ifdef HAVE_UNISTD_H
#include <unistd.h>