[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>
This commit is contained in:
@@ -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'):
|
||||
|
||||
Reference in New Issue
Block a user