From d93200694101a7cae8d5dc86044f7684ac65b8af Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 3 Oct 2020 13:45:13 +0200 Subject: [PATCH] Handle unicode in pads --- etherpump/commands/pull.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/etherpump/commands/pull.py b/etherpump/commands/pull.py index 567d1ca..35768cf 100644 --- a/etherpump/commands/pull.py +++ b/etherpump/commands/pull.py @@ -348,7 +348,14 @@ async def handle_pad(args, padid, data, info, session): ver["path"] = p + raw_ext ver["url"] = quote(ver["path"]) async with await trio.open_file(ver["path"], "w") as f: - await f.write(text) + try: + # Note(decentral1se): unicode handling... + safe_text = text.encode("utf-8", "replace").decode() + await f.write(safe_text) + except Exception as exception: + print(path) + print("PANIC: {}".format(exception)) + # once the content is settled, compute a hash # and link it in the metadata!