Prevent generation of infinite redirections
This commit is contained in:
@@ -201,6 +201,8 @@ impl<'tcx> Context<'tcx> {
|
||||
} else {
|
||||
tyname.as_str()
|
||||
};
|
||||
|
||||
if !self.render_redirect_pages {
|
||||
let page = layout::Page {
|
||||
css_class: tyname_s,
|
||||
root_path: &self.root_path(),
|
||||
@@ -212,8 +214,6 @@ impl<'tcx> Context<'tcx> {
|
||||
extra_scripts: &[],
|
||||
static_extra_scripts: &[],
|
||||
};
|
||||
|
||||
if !self.render_redirect_pages {
|
||||
layout::render(
|
||||
&self.shared.layout,
|
||||
&page,
|
||||
@@ -223,6 +223,13 @@ impl<'tcx> Context<'tcx> {
|
||||
)
|
||||
} else {
|
||||
if let Some(&(ref names, ty)) = self.cache().paths.get(&it.def_id.expect_def_id()) {
|
||||
if self.current.len() + 1 != names.len()
|
||||
|| self.current.iter().zip(names.iter()).any(|(a, b)| a != b)
|
||||
{
|
||||
// We checked that the redirection isn't pointing to the current file,
|
||||
// preventing an infinite redirection loop in the generated
|
||||
// documentation.
|
||||
|
||||
let mut path = String::new();
|
||||
for name in &names[..names.len() - 1] {
|
||||
path.push_str(&name.as_str());
|
||||
@@ -242,6 +249,7 @@ impl<'tcx> Context<'tcx> {
|
||||
None => return layout::redirect(&format!("{}{}", self.root_path(), path)),
|
||||
}
|
||||
}
|
||||
}
|
||||
String::new()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user