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

[BUG]: volt upper filter does not work on special local characters #16543

Closed
kowach opened this issue Mar 12, 2024 · 5 comments
Closed

[BUG]: volt upper filter does not work on special local characters #16543

kowach opened this issue Mar 12, 2024 · 5 comments
Assignees
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium

Comments

@kowach
Copy link

kowach commented Mar 12, 2024

After upgrading from Phalcon 4 to Phalcon 5.5 upper filter in volt does not work on utf8 characters.

Steps to reproduce the behavior:

  1. In volt template file:
{{ 'abc čžé'|upper }}

Results ABC čžé (only english letters are changed)

  1. Doing the same thing in PHP:
echo (new \Phalcon\Filter\Sanitize\Upper())->__invoke('abc čžé');

Outputs is OK ABC ČŽÉ

The function is pretty simple Upper.zep
This could only happen if function_exists("mb_convert_case") returns false, but I don't see how.

Details

  • Phalcon version: 5.5
  • PHP Version: 8.1.27
  • Operating System: Ubuntu/RockyLinux
  • Installation type: Compiling from source
  • Zephir version: 0.17.0-9f99da6
  • Server: Nginx
@kowach kowach added bug A bug report status: unverified Unverified labels Mar 12, 2024
@s-ohnishi
Copy link

Volt's compiler seems to directly rewrite {{ 'abc čžé'|upper }} to strtoupper() instead of using Phalcon\Filter\Sanitize\Upper().
Compiler.zep

It seems that v4 calls Phalcon\Text::upper().
Compiler.zep(v4.1.0)

I'm not sure which is preferable.
Just as Tag has been migrated to TagFactory, this is also in the middle of migration, so I'm not sure if it's temporary or not.
And which is generally expected when you want to change to uppercase? ABC čžé or ABC ČŽÉ?

@niden
Copy link
Member

niden commented Mar 12, 2024

The Text component was removed in favor of the helper/tag factories.

You can achieve what you want by doing this:

{{ helper.upper('abc čžé') }}

I know this might not be ideal because you might have similar code all around the place, but this is the way to get the UTF-8 functions to help you there (vs. the strtoupper())

This assumes you have the mbstring extension loaded and in your container you have a service called helper which points to the Phalcon\Support\HelperFactory. If you are using the FactoryDefault container it is already in there.

@s-ohnishi
Copy link

So this is not a bug and we can now choose according to our needs, right?

@niden
Copy link
Member

niden commented Mar 13, 2024

Actually it is a bug, since it changes the behavior from v4 to v5. What I posted above is a workaround.

I will make the necessary adjustments for this and have it use the helper if available and fall back to strtoupper if not

@niden niden self-assigned this Mar 13, 2024
@niden niden added status: medium Medium 5.0 The issues we want to solve in the 5.0 release and removed status: unverified Unverified labels Mar 13, 2024
@niden niden mentioned this issue Mar 13, 2024
5 tasks
@niden
Copy link
Member

niden commented Mar 13, 2024

This has been resolved with #16545

Thank you @kowach and @s-ohnishi

@niden niden closed this as completed Mar 13, 2024
@niden niden added this to Phalcon v5 Mar 13, 2024
@niden niden moved this to Implemented in Phalcon v5 Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium
Projects
Status: Implemented
Development

No branches or pull requests

3 participants