about summary refs log tree commit diff stats
path: root/WWW/Library
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2019-08-24 00:37:02 +0000
committerThomas E. Dickey <dickey@invisible-island.net>2019-08-24 00:37:02 +0000
commit8aea9066248d82b48dd83b99ad62015feb46ccb2 (patch)
tree7e7ec03951cc36909ea84f42f02305593e9d9ec9 /WWW/Library
parenta803e26dcdc6652b12d05f29bbd1b23c4b4239ed (diff)
downloadlynx-snapshots-8aea9066248d82b48dd83b99ad62015feb46ccb2.tar.gz
snapshot of project "lynx", label v2-9-0dev_2c
Diffstat (limited to 'WWW/Library')
-rw-r--r--WWW/Library/Implementation/HTAccess.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/WWW/Library/Implementation/HTAccess.c b/WWW/Library/Implementation/HTAccess.c
index ef33b877..a79a8a24 100644
--- a/WWW/Library/Implementation/HTAccess.c
+++ b/WWW/Library/Implementation/HTAccess.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTAccess.c,v 1.84 2018/05/11 21:36:35 tom Exp $
+ * $LynxId: HTAccess.c,v 1.85 2019/08/24 00:27:06 tom Exp $
  *
  *		Access Manager					HTAccess.c
  *		==============
@@ -724,8 +724,22 @@ HTStream *HTSaveStream(HTParentAnchor *anchor)
     return p->saveStream(anchor);
 }
 
+int redirection_limit = 10;
 int redirection_attempts = 0;	/* counter in HTLoadDocument */
 
+static BOOL too_many_redirections(void)
+{
+    if (redirection_attempts > redirection_limit) {
+	char *msg = NULL;
+
+	HTSprintf0(&msg, TOO_MANY_REDIRECTIONS, redirection_limit);
+	free(msg);
+	redirection_attempts = 0;
+	return TRUE;
+    }
+    return FALSE;
+}
+
 /*	Load a document - with logging etc		HTLoadDocument()
  *	----------------------------------
  *
@@ -765,16 +779,7 @@ static BOOL HTLoadDocument(const char *full_address,	/* may include #fragment */
     FREE(use_this_url_instead);
     permanent_redirection = FALSE;
 
-    /*
-     * Make sure some yoyo doesn't send us 'round in circles with redirecting
-     * URLs that point back to themselves.  We'll set the original Lynx limit
-     * of 10 redirections per requested URL from a user, because the HTTP/1.1
-     * will no longer specify a restriction to 5, but will leave it up to the
-     * browser's discretion, in deference to Microsoft.  - FM
-     */
-    if (redirection_attempts > 10) {
-	redirection_attempts = 0;
-	HTAlert(TOO_MANY_REDIRECTIONS);
+    if (too_many_redirections()) {
 	return NO;
     }
 
@@ -816,9 +821,8 @@ static BOOL HTLoadDocument(const char *full_address,	/* may include #fragment */
 	    /*
 	     * Don't exceed the redirection_attempts limit.  - FM
 	     */
-	    if (++redirection_attempts > 10) {
-		HTAlert(TOO_MANY_REDIRECTIONS);
-		redirection_attempts = 0;
+	    ++redirection_attempts;
+	    if (too_many_redirections()) {
 		FREE(use_this_url_instead);
 		return NO;
 	    }