diff --git a/addons/point_of_sale/controllers/main.py b/addons/point_of_sale/controllers/main.py
index 0fca1369384..1dcebd32ef1 100644
--- a/addons/point_of_sale/controllers/main.py
+++ b/addons/point_of_sale/controllers/main.py
@@ -22,7 +22,7 @@ class PosController(http.Controller):
return werkzeug.utils.redirect('/web#action=point_of_sale.action_client_pos_menu')
pos_sessions.login()
context = {
- 'session_info': json.dumps(request.env['ir.http'].session_info())
+ 'session_info': request.env['ir.http'].session_info()
}
return request.render('point_of_sale.index', qcontext=context)
diff --git a/addons/point_of_sale/views/pos_templates.xml b/addons/point_of_sale/views/pos_templates.xml
index cb1a8a81a01..05804c58711 100644
--- a/addons/point_of_sale/views/pos_templates.xml
+++ b/addons/point_of_sale/views/pos_templates.xml
@@ -28,11 +28,11 @@
diff --git a/addons/web/models/ir_http.py b/addons/web/models/ir_http.py
index f2bfc70f9b4..6c3dac17193 100644
--- a/addons/web/models/ir_http.py
+++ b/addons/web/models/ir_http.py
@@ -18,7 +18,7 @@ class Http(models.AbstractModel):
def webclient_rendering_context(self):
return {
'menu_data': request.env['ir.ui.menu'].load_menus(request.session.debug),
- 'session_info': json.dumps(self.session_info()),
+ 'session_info': self.session_info(),
}
def session_info(self):
diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml
index aa3f67af07d..e67005f0eaf 100644
--- a/addons/web/views/webclient_templates.xml
+++ b/addons/web/views/webclient_templates.xml
@@ -833,7 +833,7 @@
+
+
+ """
+ })
+ rendered = view.render({'malicious': '1 but doesn't
+ interpret anything else, this means standard htmlescaping does not
+ work (it breaks double quotes, and e.g. `<` will become `<` *in
+ the resulting JSON/JS* not just inside the page).
+
+ However, failing to escape embedded json means the json strings could
+ contains `` and thus become XSS vector.
+
+ The solution turns out to be very simple: use JSON-level unicode
+ escapes for HTML-unsafe characters (e.g. "<" -> "\u003C". This removes
+ the XSS issue without breaking the json, and there is no difference to
+ the end result once it's been parsed back from JSON. So it will work
+ properly even for HTML attributes or raw text.
+
+ Also handle U+2028 and U+2029 the same way just in case as these are
+ interpreted as newlines in javascript but not in JSON, which could
+ lead to oddities and issues.
+
+ .. warning::
+
+ except inside