mistercrunch commented on a change in pull request #11704:
URL: 
https://github.com/apache/incubator-superset/pull/11704#discussion_r523609144



##########
File path: superset/jinja_context.py
##########
@@ -229,22 +277,28 @@ def __init__(
             "filter_values": filter_values,
             "form_data": {},
         }
+
         self._context.update(kwargs)
         self._context.update(jinja_base_context)
+
         if self.engine:
             self._context[self.engine] = self
-        self._env = SandboxedEnvironment()
 
-    def process_template(self, sql: str, **kwargs: Any) -> str:
-        """Processes a sql template
 
-        >>> sql = "SELECT '{{ datetime(2017, 1, 1).isoformat() }}'"
-        >>> process_template(sql)
-        "SELECT '2017-01-01T00:00:00'"
-        """
-        template = self._env.from_string(sql)
-        kwargs.update(self._context)
-        return template.render(kwargs)
+class SafeJinjaTemplateProcessor(BaseTemplateProcessor):
+    def set_context(self, **kwargs: Any) -> None:
+        extra_cache = ExtraCache(self._extra_cache_keys)
+        self._context = {
+            "url_param": partial(safe_proxy, extra_cache.url_param),
+            "current_user_id": partial(safe_proxy, 
extra_cache.current_user_id),
+            "current_username": partial(safe_proxy, 
extra_cache.current_username),
+            "cache_key_wrapper": partial(safe_proxy, 
extra_cache.cache_key_wrapper),
+            "filter_values": partial(safe_proxy, filter_values),
+            "form_data": {},

Review comment:
       Wondering why we need this [empty dict] key (?)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to