Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "|safe" in odoo email template in field email_from

Odoo email template is using the email_from in the email template. in that i have seen some example like

${(object.email or '')|safe}

here is the screenshot

enter image description here

in that i am getting confused with the |safe, i wanted to know the use of '|safe'.

like image 997
Alpha Geek Avatar asked Mar 30 '16 16:03

Alpha Geek


2 Answers

The framework will escape HTML automatically. But when you have to prevent the template from escaping the HTML you can use 'safe' filter. The use of safe filter on variables in which users are having control may leads to XSS (JS injection) vulnerabilities.

like image 141
Adarsh Dinesh Avatar answered Nov 03 '22 02:11

Adarsh Dinesh


Well Safe is basically a filters , Filters are separated from the variable by a pipe symbol (|). So the Output of ${(object.email or '')|safe} will be produce as ${safe(object.email or '')}.

Safe is used to preventing the template from escaping the HTML content. Safe Filter explicitly marks a string as "safe", thus it should not be automatically-escaped even if auto-escaping is enabled by the ODOO framework.

For more details please visit:

http://jinja.pocoo.org/docs/dev/templates/#working-with-manual-escaping http://jinja.pocoo.org/docs/dev/templates/#working-with-automatic-escaping

like image 23
Prakash Kumar Avatar answered Nov 03 '22 02:11

Prakash Kumar