Skip to content

Commit c3aff71

Browse files
committed
fix: fix for autoescape being disables for .j2 files
1 parent 852eeb7 commit c3aff71

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/web_interface/app.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,22 @@
66
import config
77

88

9+
class ExtendedAutoEscapeFlask(Flask):
10+
AUTOESCAPE_EXTENSIONS = (
11+
'.j2',
12+
'.jhtml',
13+
'.jinja',
14+
'.jinja2',
15+
)
16+
17+
def select_jinja_autoescape(self, filename):
18+
if filename and filename.endswith(self.AUTOESCAPE_EXTENSIONS):
19+
return True
20+
return super().select_jinja_autoescape(filename)
21+
22+
923
def create_app():
10-
app = Flask(__name__)
24+
app = ExtendedAutoEscapeFlask(__name__)
1125
app.config.from_object(__name__)
1226
app.config['SECRET_KEY'] = os.urandom(24)
1327
_add_config_to_app(app)

0 commit comments

Comments
 (0)