diff --git a/src/ui/app/routes/plugins.py b/src/ui/app/routes/plugins.py index d4afcc09f..414f71b63 100644 --- a/src/ui/app/routes/plugins.py +++ b/src/ui/app/routes/plugins.py @@ -550,19 +550,29 @@ def custom_plugin_page(plugin: str): pre_render = run_action(plugin, "pre_render", tmp_dir=tmp_page_dir) if tmp_page_dir.joinpath("template.html").is_file(): - try: - plugin_page = ( - # deepcode ignore Ssti: We trust the plugin template - Environment( - loader=FileSystemLoader((tmp_page_dir.as_posix() + "/", join(sep, "usr", "share", "bunkerweb", "ui", "templates") + "/")), - autoescape=select_autoescape(["html"]), + page_content = tmp_page_dir.joinpath("template.html").read_text(encoding="utf-8") + if page_content.startswith('{% extends "base.html" %}'): + page_content = """
+
+

+ Plugin page uses old template, therefore it will not be displayed correctly. Please update it to the new format. +

+
+
""" + else: + try: + plugin_page = ( + # deepcode ignore Ssti: We trust the plugin template + Environment( + loader=FileSystemLoader((tmp_page_dir.as_posix() + "/", join(sep, "usr", "share", "bunkerweb", "ui", "templates") + "/")), + autoescape=select_autoescape(["html"]), + ) + .from_string(page_content) + .render(pre_render=pre_render, **current_app.jinja_env.globals) ) - .from_string(tmp_page_dir.joinpath("template.html").read_text(encoding="utf-8")) - .render(pre_render=pre_render, **current_app.jinja_env.globals) - ) - except BaseException as e: - LOGGER.exception("An error occurred while rendering the plugin page") - plugin_page = f'' + except BaseException as e: + LOGGER.exception("An error occurred while rendering the plugin page") + plugin_page = f'' return render_template( "plugin_page.html",