Skip to content
Permalink
Browse files

[FIX] website: prevent endless loop if homepage is unpublished..

.. and first menu is a container with # as url.

There is a particular case where the / url would loop endlessly.

1. Unpublished the homepage /
2. Edit the menu so the first menu is a container. There is a hint telling you
   a container menu should have its URL set to `#` as a good practice.
3. This will lead to endless loop for public user as the code will check if the
   homepage can be accessed. Since it is unpublished, it will then fallback on
   the first menu which is not '/' and redirect to it.
   Sadly, the code was not expecting `#` to be handled as `/`.

opw-2081969

closes #38231

X-original-commit: cff11bd
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
  • Loading branch information...
rdeodoo authored and fw-bot committed Oct 8, 2019
1 parent 1ff8fd4 commit 42db9cafc757c34ee2b40a58cdbef630e88f0add
Showing with 1 addition and 1 deletion.
  1. +1 −1 addons/website/controllers/main.py
@@ -77,7 +77,7 @@ def index(self, **kw):
else:
top_menu = request.website.menu_id
first_menu = top_menu and top_menu.child_id and top_menu.child_id.filtered(lambda menu: menu.is_visible)
if first_menu and first_menu[0].url not in ('/', '') and (not (first_menu[0].url.startswith(('/?', '/#', ' ')))):
if first_menu and first_menu[0].url not in ('/', '', '#') and (not (first_menu[0].url.startswith(('/?', '/#', ' ')))):
return request.redirect(first_menu[0].url)

raise request.not_found()

0 comments on commit 42db9ca

Please sign in to comment.
You can’t perform that action at this time.