Detect and reject infinite redirect loops.

This will prevent kiwix/kiwix-tools#207.
This commit is contained in:
cyrillemoureaux 2018-06-30 14:48:31 +02:00 committed by Matthieu Gautier
parent 03b1750313
commit e1980d190f
1 changed files with 4 additions and 2 deletions

View File

@ -122,7 +122,6 @@ Entry Entry::getFinalEntry() const
if (final_article.good()) {
return final_article;
}
int loopCounter = 42;
final_article = article;
while (final_article.isRedirect() && loopCounter--) {
@ -131,7 +130,10 @@ Entry Entry::getFinalEntry() const
throw NoEntry();
}
}
// Prevent infinite loops.
if (final_article.isRedirect()) {
throw NoEntry();
}
return final_article;
}