gathering / unicorn-backend

Backend/API for UNICORN
https://competitions.gathering.org
MIT License
2 stars 1 forks source link

Error upon submitting formatted emojis #5

Closed eriktm closed 2 years ago

eriktm commented 3 years ago

Steps to Reproduce

Try to submit data, e.g. a new Competition, with emojis in one of the text fields.

cURL example

curl 'https://unicorn.zoodo.io/api/competitions/competitions/8/' -X PUT -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36' -H 'Referer: http://localhost:3000/admin/competitions/8' -H 'Origin: http://localhost:3000' -H 'Authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzY29wZSI6bnVsbCwiZXhwIjoxNTUyODMyMzU5LCJ1aWQiOjIsImVtYWlsIjoiam8tZW1pbEB6b29kby5ubyIsInVzZXJuYW1lIjoiODk1M2I3YmMtNGI5MC00MjQzLTk1NTUtNjQ0MmEyMzM0NjQxIiwiZmlyc3RfbmFtZSI6IkpvIEVtaWwiLCJsYXN0X25hbWUiOiJIb2xlbiIsImRpc3BsYXlfbmFtZSI6ImpvbXMiLCJpc3MiOiJPc2NhciJ9.LDPe0T4rXjbs0EXVlIYy93CLYT7LAFHi0sUUtre9BKZdxZ3jvs-vAhdD69skhXXIFm63d2c9naBpR2TTr0qxlgALlpQyDeDEYBW-AvqTkxfSa9wDO04arEkN99KtRNJpuFAaarjuSMaPgAXZLH_SA2pLxZxDd2fGqTJIvHX8FKivz9njM0iPxnCrMBsJjzncmvqSul26Cse8VD4AVqTjcMooMA9cH-A5fIkZtADrqvoVfiaojLkh8NirJIGcWq6UABG8L22Te_hraOFGFbs2C1XGbw-UGSOnvWq-VO5FAQrxECWVzUpIcZRZy0yPfIIPM9u61rL6EO-OETC2wLNAAA' -H 'content-type: application/json' --data-binary '{"name":"Test compo yo!","brief_description":"Lorem ipsum dolor sit amet, consecteturs","description":"Test compo yo!","rules":"<p>æ…“øåTest compo <strong>\ud83d</strong>\ude07</p>\n","editorState":{"enabled":false},"run_time_start":"2019-03-17T11:17:00.000Z","run_time_end":"2019-03-24T11:17:00.000Z","participant_limit":0,"genre":2,"_fileupload":{"enabled":true,"fileupload":[{"id":"73d91a73-1b73-42a4-b34a-28ad6d32e7b6","file":"archive","type":"entry","input":"Main entry"}]},"extra":{"enabled":false,"contributor_extra":null},"rsvp":false,"header_image":"https://672061c0b827554def11-ea8c7607510173b2cbad15f9892e8687.ssl.cf2.rackcdn.com/rl-birthday.f44ca8609585ba611e1277fc600f5cc1.jpg","header_credit":"Psyonix","prizes":["1234","234","34","4"],"id":8,"url":"https://unicorn.zoodo.io/api/competitions/competitions/8/","published":false,"state":{"value":8,"label":"Currently Running"},"entries_count":0,"entries":[],"show_time_start":null,"show_time_end":null,"team_required":false,"created":"2019-03-17T11:52:29.630543+01:00","last_updated":"2019-03-17T14:58:16.722641+01:00","next_state":{"value":256,"label":"Finished"},"fileupload":[{"id":"73d91a73-1b73-42a4-b34a-28ad6d32e7b6","file":"archive","type":"entry","input":"Main entry"}],"register_time_start":null,"register_time_end":null,"team_min":null,"team_max":null,"vote_time_start":null,"vote_time_end":null}' --compressed

Expected Behavior

The request should be successful and, in the above example, the competition should be created.

Observed Behavior

An Exception is thrown in the save() method of the Competition model, on the last line calling super().

UnicodeEncodeError: 'utf-8' codec can't encode character '\ud83d' in position 22: surrogates not allowed

eriktm commented 2 years ago

Unable to reproduce this issue, seems to have been fixed.