[FIX] Url mismatch redirection should only be done for GET and HEAD http verbs
authorFabien Meghazi <fme@openerp.com>
Tue, 29 Apr 2014 09:56:43 +0000 (11:56 +0200)
committerFabien Meghazi <fme@openerp.com>
Tue, 29 Apr 2014 09:56:43 +0000 (11:56 +0200)
bzr revid: fme@openerp.com-20140429095643-hmq1t45tgv3opyh8

addons/website/models/ir_http.py

index c35102c..acceed1 100644 (file)
@@ -93,12 +93,13 @@ class ir_http(orm.AbstractModel):
         except Exception:
             return self._handle_exception(werkzeug.exceptions.NotFound())
 
-        generated_path = werkzeug.url_unquote_plus(path)
-        current_path = werkzeug.url_unquote_plus(request.httprequest.path)
-        if generated_path != current_path:
-            if request.lang != request.website.default_lang_code:
-                path = '/' + request.lang + path
-            return werkzeug.utils.redirect(path)
+        if request.httprequest.method in ('GET', 'HEAD'):
+            generated_path = werkzeug.url_unquote_plus(path)
+            current_path = werkzeug.url_unquote_plus(request.httprequest.path)
+            if generated_path != current_path:
+                if request.lang != request.website.default_lang_code:
+                    path = '/' + request.lang + path
+                return werkzeug.utils.redirect(path)
 
     def _serve_attachment(self):
         domain = [('type', '=', 'binary'), ('url', '=', request.httprequest.path)]