Set autoescape to True in Jinja2 environment 22/12422/3
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 2 Aug 2022 13:12:18 +0000 (15:12 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 16 Aug 2022 15:54:15 +0000 (17:54 +0200)
Change-Id: Iae6b37db0fd0a3192a68b1db86a0d79704a93a69
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_lcm/ns.py

index ae151db..118b31e 100644 (file)
@@ -30,6 +30,7 @@ from jinja2 import (
     TemplateNotFound,
     StrictUndefined,
     UndefinedError,
+    select_autoescape,
 )
 
 from osm_lcm import ROclient
@@ -414,7 +415,10 @@ class NsLcm(LcmBase):
     @staticmethod
     def _parse_cloud_init(cloud_init_text, additional_params, vnfd_id, vdu_id):
         try:
-            env = Environment(undefined=StrictUndefined, autoescape=True)
+            env = Environment(
+                      undefined=StrictUndefined,
+                      autoescape=select_autoescape(default_for_string=True, default=True),
+                  )
             template = env.from_string(cloud_init_text)
             return template.render(additional_params or {})
         except UndefinedError as e: