-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
[5.x] Use multibyte methods for obfuscate #10201
[5.x] Use multibyte methods for obfuscate #10201
Conversation
Are you able to provide an example that was previously erroring before this fix? |
Hi @duncanmcclean, I'm going to create an example repo. Might take a while though. |
Or update |
Hi @jasonvarga, I added a test with mutlibyte characters é and ß. They fail if I use |
Hm, now the random test is failing 🤔 "The same value was returned multiple times." I can't really grasp, how my changes affect the random test with the query builder input. Did the random method return the same value by coincidence? 🤔 Do you have an idea to that? |
It's probably not related to your changes. That test fails every now and then 😅 . I've re-run the failing tests. |
I noticed that the test we had already wasn't really testing it properly: $modified = $this->modify('A');
$this->assertTrue(in_array($modified, ['A', 'A', 'A'])); The When you added your test, it was still passing because one of the options was On top of all that, the This modifier is from an old package that we brought into core. We didn't actually write it. 😅 Anyway! I've updated the test and implementation. Now stuff gets obfuscated and tested correctly. |
Awesome, thanks you! |
I encountered a bug with using livewire (v3) with Statamic v5 that told me "Malformed UTF-8 characters, possibly incorrectly encoded". After some digging I found out that the obfuscate modifier caused the trouble. I also found out that since PHP 8.2 the
utf8_encode()
is deprecated and should be replaced with a multibyte encoding method. All of this led me to tryingmb_str_split()
andmb_ord()
for the obfuscate modifier. I reckon the error was caused by a multibyte character in my content and with the multibyte method equivalents I was able to fix it.Unfortunately I can't really expand on that problem any further, but I think it should be safely replaceable, since the methods just widen the range of values above 128.