Fix infinite loop when handling utf-8

This commit is contained in:
cuom1999 2022-01-05 16:18:59 +07:00
parent c2fa394e7a
commit 1f14ef7747

View file

@ -286,7 +286,11 @@ def get_problem_case(problem, files):
s.decode('utf-8')
break
except UnicodeDecodeError:
s += f.read(1)
next_char = f.read(1)
if next_char:
s += next_char
else:
raise Exception('File %s is not able to decode in utf-8' % file)
qs = get_visible_content(s)
cache.set(cache_key, qs, 86400)
result[file] = qs