Skip to content

Commit

Permalink
Handle case where the redirect target is bad
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Jul 24, 2024
1 parent 315d908 commit 8c7fdb7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions test-website/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
redir /bad-redir-loop-B /bad-redir-loop-C 307
redir /bad-redir-loop-C /bad-redir-loop-D 307
redir /bad-redir-loop-D /bad-redir-loop-B 307
redir /bad-redir-target https://I%20mNotAhostname 307

header /content-types/script1.js Content-Type application/javascript
header /content-types/script2.js Content-Type text/javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@

<body>

<h2>Redirection loops</h2>
<h2>Bad redirections</h2>

<p>Links below are indefinitely redirecting</p>
<p>Links below are indefinitely redirecting and hence not working</p>

<p><a href="/bad-redir-loop-B">Redirect to self through loop</a></p>

<p><a href="/bad-redir-loop-A">Redirect to inner-loop</a></p>

<p>Links below is targeting something which is not working</p>

<p><a href="/bad-redir-target">Redirect to silly URL</a></p>

</body>

</html>
2 changes: 1 addition & 1 deletion test-website/content/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<li><a href="./base-href.html">Base href</a></li>
<li><a href="./onxxx.html">onxxx HTML events</a></li>
<li><a href="./href-to-folder/">links to folder instead of file</a></li>
<li><a href="./redirection-loops.html">Bad redirections loops</a></li>
<li><a href="./bad-redirections.html">Bad redirections</a></li>
<li><a href="./content-types/index.html">Handling of content types</a></li>
</ul>
</body>
Expand Down
3 changes: 2 additions & 1 deletion tests/test_warc_to_zim.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ def test_redirection_loops(self, tmp_path):
zim_output = tmp_path / zim_output

for exising_website_items in [
"redirection-loops.html",
"bad-redirects.html",
]:
self.assert_item_exist(
zim_output, f"website.test.openzim.org/{exising_website_items}"
Expand All @@ -816,6 +816,7 @@ def test_redirection_loops(self, tmp_path):
"/bad-redir-loop-B",
"/bad-redir-loop-C",
"/bad-redir-loop-D",
"/bad-redir-target",
]:
self.assert_item_does_not_exist(
zim_output, f"website.test.openzim.org/{ignored_website_items}"
Expand Down

0 comments on commit 8c7fdb7

Please sign in to comment.