Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ticket/16524] Fix using out-of-bounds UTF8 characters in profile fields #6006

Merged
merged 5 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions phpBB/phpbb/profilefields/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,13 @@ public function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error)
/** @var \phpbb\profilefields\type\type_interface $profile_field */
$profile_field = $this->type_collection[$row['field_type']];
$cp_data['pf_' . $row['field_ident']] = $profile_field->get_profile_field($row);

/**
* Replace Emoji and other 4bit UTF-8 chars not allowed by MySQL
* with their Numeric Character Reference's Hexadecimal notation.
*/
$cp_data['pf_' . $row['field_ident']] = utf8_encode_ucr($cp_data['pf_' . $row['field_ident']]);

$check_value = $cp_data['pf_' . $row['field_ident']];

if (($cp_result = $profile_field->validate_profile_field($check_value, $row)) !== false)
Expand Down
19 changes: 19 additions & 0 deletions tests/functional/ucp_profile_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,23 @@ public function test_submitting_profile_info()
$this->assertEquals('phpbb_twitter', $form->get('pf_phpbb_twitter')->getValue());
$this->assertEquals('phpbb.youtube', $form->get('pf_phpbb_youtube')->getValue());
}

public function test_submitting_emoji()
{
$this->add_lang('ucp');
$this->login();

$crawler = self::request('GET', 'ucp.php?i=ucp_profile&mode=profile_info');
$this->assertContainsLang('UCP_PROFILE_PROFILE_INFO', $crawler->filter('#cp-main h2')->text());

$form = $crawler->selectButton('Submit')->form([
'pf_phpbb_location' => '😁', // grinning face with smiling eyes Emoji
]);
$crawler = self::submit($form);
$this->assertContainsLang('PROFILE_UPDATED', $crawler->filter('#message')->text());

$crawler = self::request('GET', 'ucp.php?i=ucp_profile&mode=profile_info');
$form = $crawler->selectButton('Submit')->form();
$this->assertEquals('😁', $form->get('pf_phpbb_location')->getValue());
}
}