--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/jinja2Templates.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/jinja2Templates.py Wed Jul 13 14:55:47 2022 +0200 @@ -21,7 +21,7 @@ def getChecks(): """ Public method to get a dictionary with checks handled by this module. - + @return dictionary containing checker lists containing checker function and list of codes @rtype dict @@ -36,7 +36,7 @@ def checkJinja2Autoescape(reportError, context, config): """ Function to check for not auto escaping in jinja2. - + @param reportError function to be used to report errors @type func @param context security context object @@ -45,18 +45,15 @@ @type dict """ if isinstance(context.callFunctionNameQual, str): - qualnameList = context.callFunctionNameQual.split('.') + qualnameList = context.callFunctionNameQual.split(".") func = qualnameList[-1] - if 'jinja2' in qualnameList and func == 'Environment': + if "jinja2" in qualnameList and func == "Environment": for node in ast.walk(context.node): if isinstance(node, ast.keyword): # definite autoescape = False - if ( - getattr(node, 'arg', None) == 'autoescape' and - ( - getattr(node.value, 'id', None) == 'False' or - getattr(node.value, 'value', None) is False - ) + if getattr(node, "arg", None) == "autoescape" and ( + getattr(node.value, "id", None) == "False" + or getattr(node.value, "value", None) is False ): reportError( context.node.lineno - 1, @@ -66,19 +63,23 @@ "H", ) return - + # found autoescape - if getattr(node, 'arg', None) == 'autoescape': - value = getattr(node, 'value', None) + if getattr(node, "arg", None) == "autoescape": + value = getattr(node, "value", None) if ( - getattr(value, 'id', None) == 'True' or - getattr(value, 'value', None) is True or - (isinstance(value, ast.Call) and - (getattr(value.func, 'id', None) == - 'select_autoescape')) + getattr(value, "id", None) == "True" + or getattr(value, "value", None) is True + or ( + isinstance(value, ast.Call) + and ( + getattr(value.func, "id", None) + == "select_autoescape" + ) + ) ): return - + else: reportError( context.node.lineno - 1, @@ -88,7 +89,7 @@ "M", ) return - + # We haven't found a keyword named autoescape, indicating default # behavior reportError(