@@ -65,6 +65,19 @@ public function action_whoSet()
6565 }
6666 }
6767
68+ /**
69+ * Replace emojis with placeholder to avoid database encoding issues
70+ * @param string $string
71+ * @return string
72+ */
73+ private function removeEmojis ($ string )
74+ {
75+ /**
76+ * Replace 4-byte UTF-8 characters (emojis) with [Emoji] placeholder
77+ */
78+ return preg_replace ('/[\x{10000}-\x{10FFFF}]/u ' , '[Emoji] ' , $ string );
79+ }
80+
6881 public function action_process_join_form ()
6982 {
7083 $ this ->auto_render = false ;
@@ -93,16 +106,22 @@ public function action_process_join_form()
93106 return ;
94107 }
95108
109+ /**
110+ * Get sanitized values
111+ */
96112 $ name = HTML ::chars (Arr::get ($ _POST , 'name ' , null ));
97113 $ email = HTML ::chars (Arr::get ($ _POST , 'email ' , null ));
98114 $ skills = HTML ::chars (Arr::get ($ _POST , 'skills ' ));
99115 $ wishes = HTML ::chars (Arr::get ($ _POST , 'wishes ' ));
100116
117+ /**
118+ * Remove emojis before saving to database to avoid encoding errors
119+ */
101120 $ fields = array (
102- 'skills ' => $ skills ,
103- 'wishes ' => $ wishes ,
104- 'email ' => $ email ,
105- 'name ' => $ name
121+ 'skills ' => $ this -> removeEmojis ( $ skills) ,
122+ 'wishes ' => $ this -> removeEmojis ( $ wishes) ,
123+ 'email ' => $ this -> removeEmojis ( $ email) ,
124+ 'name ' => $ this -> removeEmojis ( $ name)
106125 );
107126
108127 if (!$ fields ['email ' ] && !$ this ->user ->id ) {
0 commit comments