From 2df56d2de23229b670d9fbc8b345aadaf0812707 Mon Sep 17 00:00:00 2001 From: kakwa Date: Wed, 6 Feb 2019 21:38:11 +0100 Subject: [PATCH] fix template over-escaping + python 3 support The templates were html escaping the generated js code for the autofill and the role management. This was breaking these features. It's okay to not escape these as they are coming from a trusted source (configuration file). Also make the templates python3 compatible (not need to import Set in python 3) --- resources/templates/base.tmpl | 2 +- resources/templates/form.tmpl | 9 ++++++--- resources/templates/roles.tmpl | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/resources/templates/base.tmpl b/resources/templates/base.tmpl index eed3e54..2c25f8a 100644 --- a/resources/templates/base.tmpl +++ b/resources/templates/base.tmpl @@ -58,7 +58,7 @@ % if notifications: % for notif in notifications: - + % endfor % endif
diff --git a/resources/templates/form.tmpl b/resources/templates/form.tmpl index 243b173..3c87e11 100644 --- a/resources/templates/form.tmpl +++ b/resources/templates/form.tmpl @@ -86,8 +86,11 @@ ${form_col(lc2)}
% if autofill: <% -from sets import Set -attr_set = Set([]) +import sys +if sys.version < '3': + from sets import Set as set + +attr_set = set([]) attr_events = {} functions = {} for attrid in attributes: @@ -122,7 +125,7 @@ if (fields['${attrid}'] != null) { fields['${attrid}'].onchange = function () { % for tuple in attr_events[attrid]: if (typeof(${tuple[1]}) == "function") { - fields['${tuple[0]}'].value = ${tuple[1]}(${', '.join(functions[tuple])}); + fields['${tuple[0]}'].value = ${tuple[1] | n}(${', '.join(functions[tuple]) | n}); } % endfor }; diff --git a/resources/templates/roles.tmpl b/resources/templates/roles.tmpl index d97457d..5fa6ac3 100644 --- a/resources/templates/roles.tmpl +++ b/resources/templates/roles.tmpl @@ -1,7 +1,7 @@ ## -*- coding: utf-8 -*-