Browse Source

Handle unicode in pads

main
Luke Murphy 4 years ago
parent
commit
d932006941
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 9
      etherpump/commands/pull.py

9
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!

Loading…
Cancel
Save