Skip to content

Commit 5a0c6c7

Browse files
committed
Allow short name field to accept multibyte chars, just not emoji
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 36fddbd commit 5a0c6c7

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

event/listener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,15 @@ public function validate_pwa_options($event)
226226

227227
$short_name = $event['cfg_array']['pwa_short_name'];
228228

229-
// Do not allow multibyte characters or emoji
230-
if (strlen($short_name) !== mb_strlen($short_name, 'UTF-8'))
229+
// Do not allow emoji
230+
if (preg_match('/[\x{1F000}-\x{1F9FF}]|[\x{2600}-\x{27FF}]|[\x{1F300}-\x{1F64F}]|[\x{1F680}-\x{1F6FF}]|[\x{2700}-\x{27BF}]|[\x{FE00}-\x{FE0F}]/u', $short_name))
231231
{
232232
$this->add_error($event, 'PWA_SHORT_NAME_INVALID');
233233
return;
234234
}
235235

236236
// Do not allow strings longer than 12 characters
237-
if (strlen($short_name) > 12)
237+
if (mb_strlen($short_name, 'UTF-8') > 12)
238238
{
239239
$this->add_error($event, 'PWA_SHORT_NAME_INVALID');
240240
return;

0 commit comments

Comments
 (0)