From 117d63cca5b416bed84ca218a30f44e40e3d166b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 19 Oct 2018 15:06:16 +0200 Subject: [PATCH] update: use 'replace' mode to handle non-UTF8 description files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fastlane/Triple-T app store metadata files must be in UTF-8. Before this would crash if they were not. This changes the handling to just replace the non-UTF8 chars with a �. Here's the stacktrace: CRITICAL: Unknown exception found! Traceback (most recent call last): File "/var/lib/jenkins/userContent/reproducible/reproducible_fdroid_build_apps/fdroid", line 164, in main() File "/var/lib/jenkins/userContent/reproducible/reproducible_fdroid_build_apps/fdroid", line 159, in main raise e File "/var/lib/jenkins/userContent/reproducible/reproducible_fdroid_build_apps/fdroid", line 138, in main mod.main() File "/var/lib/jenkins/userContent/reproducible/reproducible_fdroid_build_apps/fdroidserver/update.py", line 2010, in main insert_localized_app_metadata(apps) File "/var/lib/jenkins/userContent/reproducible/reproducible_fdroid_build_apps/fdroidserver/update.py", line 885, in insert_localized_app_metadata os.path.join(root, f)) File "/var/lib/jenkins/userContent/reproducible/reproducible_fdroid_build_apps/fdroidserver/update.py", line 700, in _set_localized_text_entry text = fp.read()[:limit] File "/usr/lib/python3.5/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 94: invalid start byte --- fdroidserver/update.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 6c7281e1..2862e07e 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -695,7 +695,7 @@ def _get_localized_dict(app, locale): def _set_localized_text_entry(app, locale, key, f): limit = config['char_limits'][key] localized = _get_localized_dict(app, locale) - with open(f) as fp: + with open(f, errors='replace') as fp: text = fp.read()[:limit] if len(text) > 0: localized[key] = text @@ -703,7 +703,7 @@ def _set_localized_text_entry(app, locale, key, f): def _set_author_entry(app, key, f): limit = config['char_limits']['author'] - with open(f) as fp: + with open(f, errors='replace') as fp: text = fp.read()[:limit] if len(text) > 0: app[key] = text