summaryrefslogtreecommitdiff
path: root/addons/website_blog
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2020-02-14 17:23:17 +0000
committerJeremy Kersten <jke@odoo.com>2020-02-21 12:30:15 +0000
commite6997dae2bc4e1c4fbc2de3a8e6fa33967db5b33 (patch)
tree687ab21553e7f0b7c48b2d123aa0096ef4be34fd /addons/website_blog
parent01028b1cf3ae8f48db9c553f5cfe9be4751d7e1b (diff)
[FIX] website_blog: avoid loop of redirect if no trailing / in tag
Before this commit in case you start on blog with url like /blog/blog-1/tag/2, you should be redirected to /blog/blog-1/tag/website-2 to avoid duplicate content. But because the replace was done with /tag/%s/ it will be not replaced and so you are redirected to the same url, creating a loop. closes odoo/odoo#45927 X-original-commit: 666306326cecc6ac8587b45d2dbf24c0463b33a5 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/website_blog')
-rw-r--r--addons/website_blog/controllers/main.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/website_blog/controllers/main.py b/addons/website_blog/controllers/main.py
index 737731b88a4..ee6b17ba303 100644
--- a/addons/website_blog/controllers/main.py
+++ b/addons/website_blog/controllers/main.py
@@ -71,8 +71,9 @@ class WebsiteBlog(http.Controller):
if active_tag_ids:
fixed_tag_slug = ",".join(slug(t) for t in request.env['blog.tag'].browse(active_tag_ids).exists())
if fixed_tag_slug != tags:
- return request.redirect(request.httprequest.full_path.replace("/tag/%s/" % tags, "/tag/%s/" % fixed_tag_slug, 1), 301)
-
+ new_url = request.httprequest.full_path.replace("/tag/%s" % tags, "/tag/%s" % fixed_tag_slug, 1)
+ if new_url != request.httprequest.full_path: # check that really replaced and avoid loop
+ return request.redirect(new_url, 301)
domain += [('tag_ids', 'in', active_tag_ids)]
if request.env.user.has_group('website.group_website_designer'):