From d9db0ad7e92bc71dd2885a6e7a5ea4fa4c864f83 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 11 Nov 2025 13:14:36 +0200 Subject: [PATCH] connect `--follow` argument to limit redirections count; set `5` by default (protocol specification) --- src/Controller/Cli.php | 5 +++-- src/Model/Cli/Option.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Controller/Cli.php b/src/Controller/Cli.php index 3a1a16c..81d1ed3 100755 --- a/src/Controller/Cli.php +++ b/src/Controller/Cli.php @@ -181,7 +181,7 @@ class Cli // Crawl next address... if ($this->option->crawl) { - if ($this->redirects <= 5) // @TODO optional (currently protocol spec) + if ($this->redirects <= $this->option->follow) { // Validate redirection target location if (filter_var($response->getMeta(), FILTER_VALIDATE_URL)) // @TODO resolve relative locations @@ -216,7 +216,8 @@ class Cli print( Message::red( sprintf( - _("\tredirection count reached, continue next address in queue"), + _("\tredirection limit (%d) reached, continue next address in queue"), + $this->option->follow ) ) ); diff --git a/src/Model/Cli/Option.php b/src/Model/Cli/Option.php index 19b0c64..2a8804f 100755 --- a/src/Model/Cli/Option.php +++ b/src/Model/Cli/Option.php @@ -10,7 +10,7 @@ class Option public bool $crawl = false; public int $delay = 1; public bool $external = false; - public int $follow = 0; + public int $follow = 5; public bool $help = false; public string $index = 'index.gmi'; public bool $keep = false;