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

Short Name field sanitization does not account for multi-byte characters #971

Closed
westonruter opened this issue Apr 19, 2023 · 0 comments · Fixed by #984
Closed

Short Name field sanitization does not account for multi-byte characters #971

westonruter opened this issue Apr 19, 2023 · 0 comments · Fixed by #984
Assignees
Labels
bug Something isn't working web-app-manifest Web App Manifests
Milestone

Comments

@westonruter
Copy link
Collaborator

As reported by @RavanH:

By the way, I just found that if I set a 12 character Short Name with special character in it, like “On the Rhône” it will get cut off at 11 characters after saving. The short name with a simple “o” instead of the “ô” does not suffer this issue.

Yes, this is due to having used substr() instead of mb_substr() in sanitize_short_name. I can see that using the latter will fix the issue: https://3v4l.org/DeJdr

Note that we are using the multibyte-safe function in is_name_short:

public function is_name_short( $name ) {
$name = trim( $name );
$length = function_exists( 'mb_strlen' ) ? mb_strlen( $name ) : strlen( $name );
return $length <= self::SHORT_NAME_MAX_LENGTH;
}

We just need to use it in sanitize_short_name as well.

@westonruter westonruter added bug Something isn't working web-app-manifest Web App Manifests labels Apr 19, 2023
@westonruter westonruter added this to the 0.8 milestone Apr 19, 2023
@thelovekesh thelovekesh self-assigned this May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working web-app-manifest Web App Manifests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants