Skip to content

Commit 0cdb84c

Browse files
committed
fix emoji handling on join form
1 parent ff9d3d0 commit 0cdb84c

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

www/application/classes/Controller/Pages.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

www/application/views/templates/landings/lab.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class="lab-page__description-npm"
315315
<div>
316316
<button type="submit" id="submit-button">
317317
<span class="button-text">Отправить заявку</span>
318-
<span class="button-loader" style="display: none;">
318+
<span class="button-loader">
319319
<span class="spinner"></span>
320320
Отправляем...
321321
</span>

0 commit comments

Comments
 (0)