1
0
Fork 0

enforce utf8 on more file reads

This commit is contained in:
Nick Sweeting 2021-04-10 07:22:32 -04:00
parent 193df5c8d3
commit 6a6ef63775
2 changed files with 2 additions and 2 deletions

View file

@ -298,7 +298,7 @@ DYNAMIC_CONFIG_SCHEMA: ConfigDefaultDict = {
'URL_BLACKLIST_PTN': {'default': lambda c: c['URL_BLACKLIST'] and re.compile(c['URL_BLACKLIST'] or '', re.IGNORECASE | re.UNICODE | re.MULTILINE)}, 'URL_BLACKLIST_PTN': {'default': lambda c: c['URL_BLACKLIST'] and re.compile(c['URL_BLACKLIST'] or '', re.IGNORECASE | re.UNICODE | re.MULTILINE)},
'ARCHIVEBOX_BINARY': {'default': lambda c: sys.argv[0] or bin_path('archivebox')}, 'ARCHIVEBOX_BINARY': {'default': lambda c: sys.argv[0] or bin_path('archivebox')},
'VERSION': {'default': lambda c: json.loads((Path(c['PACKAGE_DIR']) / 'package.json').read_text().strip())['version']}, 'VERSION': {'default': lambda c: json.loads((Path(c['PACKAGE_DIR']) / 'package.json').read_text(encoding='utf-8').strip())['version']},
'PYTHON_BINARY': {'default': lambda c: sys.executable}, 'PYTHON_BINARY': {'default': lambda c: sys.executable},
'PYTHON_ENCODING': {'default': lambda c: sys.stdout.encoding.upper()}, 'PYTHON_ENCODING': {'default': lambda c: sys.stdout.encoding.upper()},

View file

@ -201,7 +201,7 @@ class Snapshot(models.Model):
@cached_property @cached_property
def headers(self) -> Optional[dict]: def headers(self) -> Optional[dict]:
try: try:
return json.loads((Path(self.link_dir) / 'headers.json').read_text().strip()) return json.loads((Path(self.link_dir) / 'headers.json').read_text(encoding='utf-8').strip())
except Exception: except Exception:
pass pass
return None return None