about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r--WWW/Library/Implementation/HTAccess.h3
-rw-r--r--WWW/Library/Implementation/HTGopher.c37
2 files changed, 31 insertions, 9 deletions
diff --git a/WWW/Library/Implementation/HTAccess.h b/WWW/Library/Implementation/HTAccess.h
index 3aa9c6d9..b898535c 100644
--- a/WWW/Library/Implementation/HTAccess.h
+++ b/WWW/Library/Implementation/HTAccess.h
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTAccess.h,v 1.20 2008/01/03 00:24:16 tom Exp $
+ * $LynxId: HTAccess.h,v 1.21 2019/08/23 23:51:45 tom Exp $
  *					HTAccess:  Access manager for libwww
  *			ACCESS MANAGER
  *
@@ -24,6 +24,7 @@ extern "C" {
 #endif
     extern char *use_this_url_instead;
 
+    extern int redirection_limit;
     extern int redirection_attempts;
 
 /*      Return codes from load routines:
diff --git a/WWW/Library/Implementation/HTGopher.c b/WWW/Library/Implementation/HTGopher.c
index 865985c2..7c60af5e 100644
--- a/WWW/Library/Implementation/HTGopher.c
+++ b/WWW/Library/Implementation/HTGopher.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTGopher.c,v 1.71 2018/12/28 16:58:59 tom Exp $
+ * $LynxId: HTGopher.c,v 1.73 2019/08/25 19:59:48 tom Exp $
  *
  *			GOPHER ACCESS				HTGopher.c
  *			=============
@@ -140,7 +140,8 @@ typedef struct _CSOformgen_context {	/* For form-based CSO gateway - FM */
 /*	Matrix of allowed characters in filenames
  *	=========================================
  */
-static BOOL acceptable[256];
+static BOOL acceptable_html[256];
+static BOOL acceptable_file[256];
 static BOOL acceptable_inited = NO;
 
 static void init_acceptable(void)
@@ -149,10 +150,17 @@ static void init_acceptable(void)
     const char *good =
     "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./-_$";
 
-    for (i = 0; i < 256; i++)
-	acceptable[i] = NO;
-    for (; *good; good++)
-	acceptable[(unsigned int) *good] = YES;
+    for (i = 0; i < 256; i++) {
+	acceptable_html[i] = NO;
+	acceptable_file[i] = NO;
+    }
+    for (; *good; good++) {
+	acceptable_html[(unsigned int) *good] = YES;
+	acceptable_file[(unsigned int) *good] = YES;
+    }
+    for (good = ";?=#"; *good; ++good) {
+	acceptable_html[(unsigned int) *good] = YES;
+    }
     acceptable_inited = YES;
 }
 
@@ -224,6 +232,7 @@ static void parse_menu(const char *arg GCC_UNUSED,
     int bytes = 0;
     int BytesReported = 0;
     char buffer[128];
+    BOOL *valid_chars;
 
 #define TAB		'\t'
 #define HEX_ESCAPE	'%'
@@ -432,10 +441,22 @@ static void parse_menu(const char *arg GCC_UNUSED,
 
 		    if (gtype != GOPHER_DUPLICATE)
 			this_type = gtype;
-		    HTSprintf0(&address, "//%s/%c", host, this_type);
+
+		    if (gtype == GOPHER_HTML) {
+			valid_chars = acceptable_html;
+			HTSprintf0(&address, "//%s:%s/%c",
+				   host,
+				   isEmpty(port) ? "80" : port,
+				   this_type);
+			if (*selector == '/')
+			    ++selector;
+		    } else {
+			valid_chars = acceptable_file;
+			HTSprintf0(&address, "//%s/%c", host, this_type);
+		    }
 
 		    for (r = selector; *r; r++) {	/* Encode selector string */
-			if (acceptable[UCH(*r)]) {
+			if (valid_chars[UCH(*r)]) {
 			    HTSprintf(&address, "%c", *r);
 			} else {
 			    HTSprintf(&address, "%c%c%c",