diff options
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r-- | WWW/Library/Implementation/HTAccess.c | 6 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTFTP.c | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTMIME.c | 126 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTParse.c | 3 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTCP.c | 25 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTCP.h | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTP.c | 39 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTelnet.c | 21 | ||||
-rw-r--r-- | WWW/Library/Implementation/www_tcp.h | 7 |
9 files changed, 153 insertions, 82 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c index 1cc2b50e..42a58190 100644 --- a/WWW/Library/Implementation/HTAccess.c +++ b/WWW/Library/Implementation/HTAccess.c @@ -468,9 +468,9 @@ PRIVATE int get_physical ARGS2( } } else if (!strcasecomp(acc_method, "wais")) { /* - ** Wais also needs checking of the default port - ** for selective exclusions. - */ + ** Wais also needs checking of the default port + ** for selective exclusions. + */ char *host = NULL; if ((host = HTParse(addr, "", PARSE_HOST))) { if (!(strchr(host, ':'))) { diff --git a/WWW/Library/Implementation/HTFTP.c b/WWW/Library/Implementation/HTFTP.c index 4f279fab..42e7cad0 100644 --- a/WWW/Library/Implementation/HTFTP.c +++ b/WWW/Library/Implementation/HTFTP.c @@ -57,10 +57,6 @@ BUGS: @@@ Limit connection cache size! ** same time. */ -#if defined(DJGPP) && !defined(WATT32) -#define u_long unsigned long -#endif - #include <HTUtils.h> #include <HTAlert.h> diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c index 49de53f8..fe51cd9c 100644 --- a/WWW/Library/Implementation/HTMIME.c +++ b/WWW/Library/Implementation/HTMIME.c @@ -75,6 +75,9 @@ typedef enum { miPRAGMA, miPROXY_AUTHENTICATE, miPUBLIC, + miR, + miRE, + miREFRESH, miRETRY_AFTER, miS, miSAFE, @@ -130,6 +133,8 @@ struct _HTStream { char * set_cookie2; /* Set-Cookie2 */ char * location; /* Location */ + char * refresh_url; /* "Refresh:" URL */ + HTFormat encoding; /* Content-Transfer-Encoding */ char * compression_encoding; HTFormat format; /* Content-Type */ @@ -165,6 +170,36 @@ PUBLIC void HTMIME_TrimDoubleQuotes ARGS1( value[i] = cp[(i +1)]; } +PRIVATE char *parse_parameter ARGS2( + char *, from, + char *, name) +{ + size_t len = strlen(name); + char *result = NULL; + char *string = from; + + do { + if ((string = strchr(string, ';')) == NULL) + return NULL; + while (*string != '\0' && (*string == ';' || isspace(*string))) { + string++; + } + if (strlen(string) < len) return NULL; + } while (strncasecomp(string, name, len) != 0); + string += len; + while (*string != '\0' && (isspace(*string) || *string == '=')) { + string++; + } + + StrAllocCopy(result, string); + len = 0; + while (isprint(string[len]) && string[len] != ';') { + len++; + } + result[len] = '\0'; + return result; +} + PRIVATE int pumpData ARGS1(HTStream *, me) { if (strchr(HTAtom_name(me->format), ';') != NULL) { @@ -174,13 +209,13 @@ PRIVATE int pumpData ARGS1(HTStream *, me) HTAtom_name(me->format))); StrAllocCopy(cp, HTAtom_name(me->format)); /* - ** Note that the Content-Type value was converted - ** to lower case when we loaded into me->format, - ** but there may have been a mixed or upper-case - ** atom, so we'll force lower-casing again. We - ** also stripped spaces and double-quotes, but - ** we'll make sure they're still gone from any - ** charset parameter we check. - FM + ** Note that the Content-Type value was converted + ** to lower case when we loaded into me->format, + ** but there may have been a mixed or upper-case + ** atom, so we'll force lower-casing again. We + ** also stripped spaces and double-quotes, but + ** we'll make sure they're still gone from any + ** charset parameter we check. - FM */ LYLowerCase(cp); if ((cp1 = strchr(cp, ';')) != NULL) { @@ -432,6 +467,24 @@ PRIVATE int pumpData ARGS1(HTStream *, me) } else { me->state = MIME_IGNORE; /* What else to do? */ } + if (me->refresh_url != NULL) { + char *url = parse_parameter(me->refresh_url, "URL"); + char *txt = NULL; + int num = 0; + + if (url != NULL) { + CTRACE((tfp, "Formatting refresh-url as first line of result\n")); + while (isdigit(me->refresh_url[num])) + ++num; + HTSprintf0(&txt, gettext("Refresh: ")); + if (num != 0) + HTSprintf(&txt, gettext("%.*s seconds "), num, me->refresh_url); + HTSprintf(&txt, "<a href=\"%s\">%s</a><br>", url, url); + (me->isa->put_string)(me, txt); + free(url); + free(txt); + } + } return HT_OK; } @@ -800,6 +853,12 @@ PRIVATE int dispatchField ARGS1(HTStream *, me) CTRACE((tfp, "HTMIME: PICKED UP Public: '%s'\n", me->value)); break; + case miREFRESH: /* nonstandard: Netscape */ + HTMIME_TrimDoubleQuotes(me->value); + CTRACE((tfp, "HTMIME: PICKED UP Refresh: '%s'\n", + me->value)); + StrAllocCopy(me->refresh_url, me->value); + break; case miRETRY_AFTER: HTMIME_TrimDoubleQuotes(me->value); CTRACE((tfp, "HTMIME: PICKED UP Retry-After: '%s'\n", @@ -1032,10 +1091,8 @@ PRIVATE void HTMIME_put_character ARGS2( case 'r': case 'R': - me->check_pointer = "etry-after:"; - me->if_ok = miRETRY_AFTER; - me->state = miCHECK; - CTRACE((tfp, "HTMIME: Got 'R' at beginning of line, checking for 'etry-after'\n")); + me->state = miR; + CTRACE((tfp, "HTMIME: Got 'R' at beginning of line, state now R\n")); break; case 's': @@ -1323,6 +1380,47 @@ PRIVATE void HTMIME_put_character ARGS2( } /* switch on character */ break; + case miR: /* Check for 'e' */ + switch (c) { + case 'e': + case 'E': + me->state = miRE; + CTRACE((tfp, "HTMIME: Was R, found E\n")); + break; + default: + CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + c, "'e'")); + goto bad_field_name; + + } /* switch on character */ + break; + + case miRE: /* Check for 'a' or 'o' */ + switch (c) { + case 'f': + case 'F': /* nonstandard: Netscape */ + me->check_pointer = "resh:"; + me->if_ok = miREFRESH; + me->state = miCHECK; + CTRACE((tfp, "HTMIME: Was RE, found F, checking for '%s'\n", me->check_pointer)); + break; + + case 't': + case 'T': + me->check_pointer = "ry-after:"; + me->if_ok = miRETRY_AFTER; + me->state = miCHECK; + CTRACE((tfp, "HTMIME: Was RE, found T, checking for '%s'\n", me->check_pointer)); + break; + + default: + CTRACE((tfp, "HTMIME: Bad character `%c' found where `%s' expected\n", + c, "'f' or 't'")); + goto bad_field_name; + + } /* switch on character */ + break; + case miS: /* Check for 'a' or 'e' */ switch (c) { case 'a': @@ -1672,6 +1770,7 @@ PRIVATE void HTMIME_put_character ARGS2( case miPRAGMA: case miPROXY_AUTHENTICATE: case miPUBLIC: + case miREFRESH: case miRETRY_AFTER: case miSAFE: case miSERVER: @@ -1889,8 +1988,9 @@ PUBLIC HTStream* HTMIMEConvert ARGS3( me->format = WWW_HTML; me->targetRep = pres->rep_out; me->boundary = NULL; /* Not set yet */ - me->set_cookie = NULL; /* Not set yet */ - me->set_cookie2 = NULL; /* Not set yet */ + me->set_cookie = NULL; /* Not set yet */ + me->set_cookie2 = NULL; /* Not set yet */ + me->refresh_url = NULL; /* Not set yet */ me->encoding = 0; /* Not set yet */ me->compression_encoding = NULL; /* Not set yet */ me->net_ascii = NO; /* Local character set */ diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c index b5112341..34703652 100644 --- a/WWW/Library/Implementation/HTParse.c +++ b/WWW/Library/Implementation/HTParse.c @@ -275,7 +275,7 @@ PUBLIC char * HTParse ARGS3( /* ** Handle the host field. */ - if (wanted & PARSE_HOST) + if (wanted & PARSE_HOST) { if (given.host || related.host) { char *tail = result + strlen(result); if (wanted & PARSE_PUNCTUATION) @@ -343,6 +343,7 @@ PUBLIC char * HTParse ARGS3( } #endif /* CLEAN_URLS */ } + } /* ** If host in given or related was ended directly with a '?' (no diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c index 6660ee4a..1d5beeb1 100644 --- a/WWW/Library/Implementation/HTTCP.c +++ b/WWW/Library/Implementation/HTTCP.c @@ -32,7 +32,7 @@ #include <resolv.h> #endif -#if defined(__DJGPP__) && defined (WATT32) +#ifdef __DJGPP__ #include <netdb.h> #endif /* __DJGPP__ */ @@ -381,8 +381,6 @@ PRIVATE void quench ARGS1( PUBLIC int lynx_nsl_status = HT_OK; -#if !( defined(__DJGPP__) && !defined(WATT32) ) /* much excluded! */ - #define DEBUG_HOSTENT /* disable in case of problems */ #define DEBUG_HOSTENT_CHILD /* for NSL_FORK, may screw up trace file */ @@ -1163,8 +1161,6 @@ failed: return NULL; } -#endif /* from here on DJGPP without WATT32 joins us again. */ - /* Parse a network node address and port ** ------------------------------------- @@ -1270,10 +1266,6 @@ PRIVATE int HTParseInet ARGS2( */ if (dotcount_ip == 3) /* Numeric node address: */ { - -#if defined(__DJGPP__) && !defined(WATT32) - soc_in->sin_addr.s_addr = htonl(aton(host)); -#else #ifdef DGUX_OLD soc_in->sin_addr.s_addr = inet_addr(host).s_addr; /* See arpa/inet.h */ #else @@ -1293,7 +1285,6 @@ PRIVATE int HTParseInet ARGS2( #endif /* HAVE_INET_ATON */ #endif /* GUSI */ #endif /* DGUX_OLD */ -#endif /* __DJGPP__ && !WATT32 */ #ifndef _WINDOWS_NSL FREE(host); #endif /* _WINDOWS_NSL */ @@ -1304,21 +1295,11 @@ PRIVATE int HTParseInet ARGS2( CTRACE((tfp, "HTParseInet: Calling LYGetHostByName(%s)\n", host)); #endif /* MVS */ -#if defined(__DJGPP__) && !defined(WATT32) - if (!valid_hostname(host)) { - FREE(host); - return HT_NOT_ACCEPTABLE; /* only HTDoConnect checks this. */ - } - soc_in->sin_addr.s_addr = htonl(resolve(host)); - if (soc_in->sin_addr.s_addr == 0) { - goto failed; - } -#else /* !(__DJGPP__ && !WATT32) */ #ifdef _WINDOWS_NSL phost = LYGetHostByName(host); /* See above */ if (!phost) goto failed; memcpy((void *)&soc_in->sin_addr, phost->h_addr, phost->h_length); -#else /* !(__DJGPP__ && !WATT32) && !_WINDOWS_NSL */ +#else /* !_WINDOWS_NSL */ { struct hostent *phost; phost = LYGetHostByName(host); /* See above */ @@ -1343,7 +1324,7 @@ PRIVATE int HTParseInet ARGS2( #endif /* VMS && CMU_TCP */ } #endif /* _WINDOWS_NSL */ -#endif /* __DJGPP__ && !WATT32 */ + #ifndef _WINDOWS_NSL FREE(host); #endif /* _WINDOWS_NSL */ diff --git a/WWW/Library/Implementation/HTTCP.h b/WWW/Library/Implementation/HTTCP.h index 91f98c80..91835980 100644 --- a/WWW/Library/Implementation/HTTCP.h +++ b/WWW/Library/Implementation/HTTCP.h @@ -87,11 +87,7 @@ extern BOOL valid_hostname PARAMS((char * name)); */ extern int lynx_nsl_status; -#if defined(__DJGPP__) && !defined(WATT32) -#define LYGetHostByName(host) resolv(host) /* we'll use it the same way */ -#else extern struct hostent * LYGetHostByName PARAMS((char * str)); -#endif /* Get Name of This Machine ** ------------------------ diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c index 7dcd0d9f..62175551 100644 --- a/WWW/Library/Implementation/HTTP.c +++ b/WWW/Library/Implementation/HTTP.c @@ -7,9 +7,6 @@ */ #include <HTUtils.h> -#if defined(__DJGPP__) && defined (WATT32) -#include <tcp.h> -#endif /* __DJGPP__ */ #include <HTTP.h> #include <LYUtils.h> @@ -324,6 +321,32 @@ PUBLIC int ws_netread(int fd, char *buf, int len) } #endif +/* + * Strip any username from the given string so we retain only the host. + * If the + */ +PRIVATE void strip_userid ARGS1( + char *, host) +{ + char *p1 = host; + char *p2 = strchr(host, '@'); + char *fake; + + if (p2 != 0) { + *p2++ = '\0'; + if ((fake = HTParse(host, "", PARSE_HOST)) != NULL) { + char *msg = NULL; + + CTRACE((tfp, "FIXME:%s\n", fake)); + HTSprintf0(&msg, gettext("Address contains a username: %s"), host); + HTAlert(msg); + FREE(msg); + } + while ((*p1++ = *p2++) != '\0') { + ; + } + } +} /* Load Document from HTTP Server HTLoadHTTP() ** ============================== @@ -626,6 +649,7 @@ use_tunnel: char * host = NULL; if ((host = HTParse(anAnchor->address, "", PARSE_HOST)) != NULL) { + strip_userid(host); HTSprintf(&command, "Host: %s%c%c", host, CR,LF); FREE(host); } @@ -989,10 +1013,9 @@ use_tunnel: ? anAnchor->post_content_type : "lose", CR, LF); -/* - * Ack! This assumes non-binary data! Icky! - * - */ + /* + * FIXME: Ack! This assumes non-binary data! Icky! + */ HTSprintf(&command, "Content-length: %d%c%c", (anAnchor->post_data) ? strlen (anAnchor->post_data) @@ -1038,7 +1061,7 @@ use_tunnel: !already_retrying && /* Don't retry if we're posting. */ !do_post) { /* - ** Arrrrgh, HTTP 0/1 compability problem, maybe. + ** Arrrrgh, HTTP 0/1 compatibility problem, maybe. */ CTRACE((tfp, "HTTP: BONZO ON WRITE Trying again with HTTP0 request.\n")); _HTProgress (RETRYING_AS_HTTP0); diff --git a/WWW/Library/Implementation/HTTelnet.c b/WWW/Library/Implementation/HTTelnet.c index 436e259f..e01043c3 100644 --- a/WWW/Library/Implementation/HTTelnet.c +++ b/WWW/Library/Implementation/HTTelnet.c @@ -33,10 +33,6 @@ #include <LYStrings.h> #include <LYLeaks.h> -#ifdef __DJGPP__ -#include <sys/exceptn.h> -#include <go32.h> -#endif /* __DJGPP__ */ PRIVATE void do_system ARGS1(char *, command) { @@ -208,22 +204,7 @@ PRIVATE int remote_session ARGS2(char *, acc_method, char *, host) break; } -#ifdef __DJGPP__ -#ifdef WATT32 - _eth_release(); -#endif /* WATT32 */ - __djgpp_set_ctrl_c(0); - _go32_want_ctrl_break(1); -#endif /* __DJGPP__ */ - do_system(command); -#ifdef __DJGPP__ - __djgpp_set_ctrl_c(1); - _go32_want_ctrl_break(0); -#ifdef WATT32 - _eth_init(); -#endif /* WATT32 */ -#endif /* __DJGPP__ */ - + LYSystem(command); #define TELNET_DONE #endif /* unix */ diff --git a/WWW/Library/Implementation/www_tcp.h b/WWW/Library/Implementation/www_tcp.h index 1a6844b5..ff8cceb3 100644 --- a/WWW/Library/Implementation/www_tcp.h +++ b/WWW/Library/Implementation/www_tcp.h @@ -558,7 +558,6 @@ extern int errno; #include <errno.h> #include <sys/types.h> #include <io.h> -#ifdef WATT32 #include <sys/socket.h> #include <arpa/inet.h> #include <tcp.h> @@ -566,9 +565,6 @@ extern int errno; #undef word #endif /* word */ #define select select_s -#else -#include <socket.h> -#endif /* WATT32 */ #undef NETWRITE #define NETWRITE write_s @@ -579,9 +575,6 @@ extern int errno; #ifdef UNIX #undef UNIX #endif /* UNIX */ -#ifndef WATT32 -#define getsockname getsockname_s -#endif /* !WATT32 */ #ifdef HAVE_GETTEXT #define gettext gettext__ #endif |