Skip to content

Display name initial for avatar should use multi-byte substring #8242

@sarunasb

Description

@sarunasb

Steps to reproduce

  1. Login to web interface.
  2. Go to own Settings → Personal info.
  3. If graphical avatar is not supplied, first initial of display name is used.
  4. If it happens to be in Unicode, as in e.g. 'Šarūnas', incorrect symbol is shown in avatar image.

Expected behaviour

A correct symbol from UTF-8 should be rendered in PNG.

Actual behaviour

lib/private/Avatar.php uses imagettftext(), which expects text in UTF-8. However initial symbol from display name is retrieved using substr()

$text = strtoupper(substr($userDisplayName, 0, 1))

which only gets the first part of the Unicode symbol, resulting in incorrect letter. Instead mb_substr() should be used, i.e.:

$text = strtoupper(mb_substr($userDisplayName, 0, 1))

Server configuration

Operating system: Ubuntu 16.04.3

Web server: Apache 2.4

Database: MySQL

PHP version: 7.0.22-0ubuntu0.16.04.1

Nextcloud version: 13.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions