fix: restore _dict, used in Jinja code

This commit is contained in:
Sagar Vora 2022-12-07 13:13:27 +05:30
parent 6e8820e627
commit f2e1dbe7eb
2 changed files with 4 additions and 0 deletions

View file

@ -75,3 +75,6 @@ class TestSafeExec(FrappeTestCase):
def test_unsafe_objects(self):
unsafe_global = {"frappe": frappe}
self.assertRaises(SyntaxError, safe_exec, """frappe.msgprint("Hello")""", unsafe_global)
def test_frappe_dict_in_jinja(self):
frappe.render_template("{% set my_dict = _dict() %} {{- my_dict.works -}}", {})

View file

@ -105,6 +105,7 @@ def get_safe_globals():
json=NamespaceDict(loads=json.loads, dumps=json.dumps),
as_json=frappe.as_json,
dict=dict,
_dict=frappe._dict, # this isn't usable with RestrictedPython, but kept for Jinja compatibility
log=frappe.log,
args=form_dict,
frappe=NamespaceDict(