From 07143dd433bbe05588f1d3fa18b451672d083bac Mon Sep 17 00:00:00 2001 From: Fritz Reichwald Date: Tue, 27 Dec 2016 20:31:57 +0100 Subject: [PATCH] Add html escape proper quotes and log call --- qutebrowser/utils/jinja.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qutebrowser/utils/jinja.py b/qutebrowser/utils/jinja.py index f2dbbfe5f..16ccb2959 100644 --- a/qutebrowser/utils/jinja.py +++ b/qutebrowser/utils/jinja.py @@ -23,6 +23,7 @@ import os import os.path import traceback import mimetypes +import html import jinja2 import jinja2.exceptions @@ -31,7 +32,7 @@ from qutebrowser.utils import utils, urlutils, log from PyQt5.QtCore import QUrl -html_fallback = ''' +html_fallback = """ @@ -57,8 +58,8 @@ html_fallback = ''' -

The error.html template could not be found!
Please check your qutebrowser installation

''' -html_fallback2 = '''

+

The error.html template could not be found!
Please check your qutebrowser installation

+%ERROR%

Unable to load page

Error while opening {{ url }}:

{{ error }}



@@ -73,7 +74,7 @@ html_fallback2 = '''

-''' +""" class Loader(jinja2.BaseLoader): @@ -91,7 +92,8 @@ class Loader(jinja2.BaseLoader): try: source = utils.read_file(path) except OSError as e: - source = html_fallback + str(e) + html_fallback2; + source = html_fallback.replace("%ERROR%", html.escape(str(e))) + log.misc.error("The error.html template could not be found" + path) # Currently we don't implement auto-reloading, so we always return True # for up-to-date. return source, path, lambda: True