From 8aea9066248d82b48dd83b99ad62015feb46ccb2 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Sat, 24 Aug 2019 00:37:02 +0000 Subject: snapshot of project "lynx", label v2-9-0dev_2c --- WWW/Library/Implementation/HTAccess.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'WWW/Library') 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; } -- cgit 1.4.1-2-gfad0