opencaching / opencaching-pl

The source code of Opencaching.PL (and some other domains)
https://opencaching.pl/
GNU General Public License v3.0
22 stars 33 forks source link

Cache title does not support UTF8 emoji #2399

Open andrixnet opened 9 months ago

andrixnet commented 9 months ago

I was trying to edit a cache with an emoji in the titles, taken from https://emojipedia.org I can paste the emoji in the title field, but upon saving, it dissapears.

stefopl commented 9 months ago

In my local environment, attempting the following SQL query: UPDATE ocpl.caches t SET t.name = 'emoji Test 🔥' WHERE t.cache_id = 86263; resulted in the error: [2023-10-01 00:55:06] [HY000][1366] Incorrect string value: '\xF0\x9F\x94\xA5' for column 'name' at row 1 To resolve this, I executed: alter table caches modify name varchar(255) collate utf8mb4_general_ci null; After this change, the database worked correctly. However, on the webpage, it displayed emoji Test ?. I solved this problem by modifying: src/Utils/Database/OcPdo.php:35 'charset' => 'utf8' to: 'charset' => 'utf8mb4'

This is just a suggestion. It needs to be thoroughly tested