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

Escaper - htmlAttrMatcher gives a wrong encoding #5

Open
weierophinney opened this issue Dec 31, 2019 · 6 comments
Open

Escaper - htmlAttrMatcher gives a wrong encoding #5

weierophinney opened this issue Dec 31, 2019 · 6 comments

Comments

@weierophinney
Copy link
Member

This issue has been moved from the zendframework repository as part of the bug migration program as outlined here - http://framework.zend.com/blog/2016-04-11-issue-closures.html


Original Issue: https://api.github.com/repos/zendframework/zendframework/issues/7621
User: @esase
Created On: 2015-08-28T16:08:25Z
Updated At: 2015-11-06T22:20:41Z
Body
I didn't see this trouble before but when I updated my Zend with the latest 2.5.1 I see the very strange behaviour. All form elements show me Chines characters like this 킞톂킿톀킰킲킸톂톌 instead of Войти (Russian) e.g.

It happens only on windows platform, on Linux everything is ok.
My work environment is:
OS: Windows
PHP: 5.4.12
Site locale: ru_RU

I found this issue here - zend-escaper\src\Escaper.php in htmlAttrMatcher($matches) method

PS: For English everything is ok


Comment

User: @esase
Created On: 2015-08-31T06:37:51Z
Updated At: 2015-08-31T06:37:51Z
Body
Anyone?



Originally posted by @GeeH at zendframework/zend-escaper#17

@weierophinney
Copy link
Member Author

Having same issue. Updated to last version. Any recommendations?


Originally posted by @smilingcheater at zendframework/zend-escaper#17 (comment)

@weierophinney
Copy link
Member Author

I have this problem too.
Is there a solution?


Originally posted by @potkot at zendframework/zend-escaper#17 (comment)

@weierophinney
Copy link
Member Author

@potkot I overrided exist escaper with my own. In module.config.php added:

'view_helpers' => [ 'factories' => [ \App\View\Helper\EscapeHtmlAttr::class => InvokableFactory::class, ], 'aliases' => [ 'escapehtmlattr' => \App\View\Helper\EscapeHtmlAttr::class, ] ]

and created new helper:

namespace App\View\Helper; class EscapeHtmlAttr extends \Zend\View\Helper\EscapeHtmlAttr { protected function escape($value) { return htmlspecialchars($value); } }


Originally posted by @smilingcheater at zendframework/zend-escaper#17 (comment)

@weierophinney
Copy link
Member Author

The correct solution is to pass in utf8 strings, as expected. A test case is needed if this persists.


Originally posted by @Ocramius at zendframework/zend-escaper#17 (comment)

@weierophinney
Copy link
Member Author

@smilingcheater Thank you very much! Working solution!


Originally posted by @potkot at zendframework/zend-escaper#17 (comment)

@weierophinney
Copy link
Member Author

No, that's a workaround, and an un-proven one.

Write a test please, then the workaround can be verified against the existing test suite and the new test.


Originally posted by @Ocramius at zendframework/zend-escaper#17 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant