zammad
zammad copied to clipboard
Lastname in Uppercase is ignored, when first name is optional
Infos:
- Used Zammad version: 5.2 and 5.0.1
- Installation method (source, package, ..): Package
- Operating system: Debian 10 & 11
- Database + version:
- Elasticsearch version:
- Browser + version:
I have an workflow, to set the first name as optional, if a lastname is given. Now, when i put an name in upper case in the last name field and left the first name field blank, then the last name is not stored in upper case, only the first character is upper case.
If the first name field is also set, the last name is stored completely in upper case.
Steps to reproduce the behavior:
- Tested with a fresh install on Debian 11/Zammad 5.2:
Create a workflow, that sets the first name as optional, if the last name is given. Now create a user with the last name in upper case like "TESTUSER", and it will be stored as "Testuser". Setting last name to e.g. "TEST" and first name to "USER" stores both values in upper case.
Yes I'm sure this is a bug and no feature request or a general question.
The same happens, when the name is in lowercase. Also this happens, if you set the lastname as optional if a first name is given. It looks like there is a auto capitalization, that has not to be there. Or there is a auto capitalization that does not work, if both the firstname and the lastname are given.
I noticed the same issue as capitalization of names synced from LDAP was not being preserved when the user had no first name. In my case: first name = '', last name = "SUPPORT" is synced as first name = '', last name = "Support"
You can also observe this when you try to run User.find(xy).update(firstname: "", lastname:"SUPPORT")
. This will update to "Support".
I traced this down to app/models/user.rb function check_name.
If first name or last name is empty when calling the function, the function (or rather the called function check_name_apply) will capitalize the name, and names in all caps will be capitalized.
If both first and last name are present, nothing will be done to them due to
return if firstname.present? && lastname.present?
I verified this is the cause by temporarily commenting out self[identifier].capitalize! if self[identifier]&.match? %r{^([[:upper:]]+|[[:lower:]]+)$}
in check_name_apply.
Capitalizing certainly is useful when the code extracts first and last name from an email address like [email protected]. This need someone with more insight and proper Ruby knowledge to address further.
To note: One of our departments communicated internationally, and they have adapted to the Asian notion of writing their last name all caps to distinguish it from the first name. For example in Japanese, the last name comes first. This can lead to confusion when communicating internationally about what is the first name and what is the last name. Therefore the custom of writing the last name all caps.
Maybe also something to consider for the code that extracts first and last name from email from-headers at customer creation ("First Last <[email protected]>").
I can confirm that this also happens in a recent 5.3.1 Zammad. Thanks to Martin-Bonn for digging deeper into the code and also providing an additional use case.