Merge pull request #4138 from lufte/issue4137
Fix double-escaping on qute://log
This commit is contained in:
commit
9a4f3dae63
@ -57,6 +57,7 @@ Fixed
|
|||||||
- Crash in the `importer.py` script when importing Chrome bookmarks from newer Chrome versions.
|
- Crash in the `importer.py` script when importing Chrome bookmarks from newer Chrome versions.
|
||||||
- The `content.webrtc_public_interfaces_only` option didn't work on Qt 5.11 previously (it now does).
|
- The `content.webrtc_public_interfaces_only` option didn't work on Qt 5.11 previously (it now does).
|
||||||
Note it still does not work on Qt 5.10 (due to a Qt bug) and Qt < 5.9.2.
|
Note it still does not work on Qt 5.10 (due to a Qt bug) and Qt < 5.9.2.
|
||||||
|
- Repeated escaping of entries in `qute://log` when refreshing page.
|
||||||
|
|
||||||
v1.4.1
|
v1.4.1
|
||||||
------
|
------
|
||||||
|
@ -25,6 +25,7 @@ import html as pyhtml
|
|||||||
import logging
|
import logging
|
||||||
import contextlib
|
import contextlib
|
||||||
import collections
|
import collections
|
||||||
|
import copy
|
||||||
import faulthandler
|
import faulthandler
|
||||||
import traceback
|
import traceback
|
||||||
import warnings
|
import warnings
|
||||||
@ -568,16 +569,14 @@ class RAMHandler(logging.Handler):
|
|||||||
https://github.com/qutebrowser/qutebrowser/issues/34
|
https://github.com/qutebrowser/qutebrowser/issues/34
|
||||||
"""
|
"""
|
||||||
minlevel = LOG_LEVELS.get(level.upper(), VDEBUG_LEVEL)
|
minlevel = LOG_LEVELS.get(level.upper(), VDEBUG_LEVEL)
|
||||||
lines = []
|
|
||||||
fmt = self.html_formatter.format if html else self.format
|
fmt = self.html_formatter.format if html else self.format
|
||||||
self.acquire()
|
self.acquire()
|
||||||
try:
|
try:
|
||||||
records = list(self._data)
|
lines = [fmt(record)
|
||||||
|
for record in self._data
|
||||||
|
if record.levelno >= minlevel]
|
||||||
finally:
|
finally:
|
||||||
self.release()
|
self.release()
|
||||||
for record in records:
|
|
||||||
if record.levelno >= minlevel:
|
|
||||||
lines.append(fmt(record))
|
|
||||||
return '\n'.join(lines)
|
return '\n'.join(lines)
|
||||||
|
|
||||||
def change_log_capacity(self, capacity):
|
def change_log_capacity(self, capacity):
|
||||||
@ -637,17 +636,18 @@ class HTMLFormatter(logging.Formatter):
|
|||||||
self._colordict['reset'] = '</font>'
|
self._colordict['reset'] = '</font>'
|
||||||
|
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
record.__dict__.update(self._colordict)
|
record_clone = copy.copy(record)
|
||||||
if record.levelname in self._log_colors:
|
record_clone.__dict__.update(self._colordict)
|
||||||
color = self._log_colors[record.levelname]
|
if record_clone.levelname in self._log_colors:
|
||||||
record.log_color = self._colordict[color]
|
color = self._log_colors[record_clone.levelname]
|
||||||
|
record_clone.log_color = self._colordict[color]
|
||||||
else:
|
else:
|
||||||
record.log_color = ''
|
record_clone.log_color = ''
|
||||||
for field in ['msg', 'filename', 'funcName', 'levelname', 'module',
|
for field in ['msg', 'filename', 'funcName', 'levelname', 'module',
|
||||||
'name', 'pathname', 'processName', 'threadName']:
|
'name', 'pathname', 'processName', 'threadName']:
|
||||||
data = str(getattr(record, field))
|
data = str(getattr(record_clone, field))
|
||||||
setattr(record, field, pyhtml.escape(data))
|
setattr(record_clone, field, pyhtml.escape(data))
|
||||||
msg = super().format(record)
|
msg = super().format(record_clone)
|
||||||
if not msg.endswith(self._colordict['reset']):
|
if not msg.endswith(self._colordict['reset']):
|
||||||
msg += self._colordict['reset']
|
msg += self._colordict['reset']
|
||||||
return msg
|
return msg
|
||||||
|
Loading…
Reference in New Issue
Block a user