Closed xurc closed 1 year ago
I’m pretty sure you have to make sure you have bytes everywhere, meaning you have to encode your data before passing it to the validator.
I’m pretty sure you have to make sure you have bytes everywhere, meaning you have to encode your data before passing it to the validator.
This is counterintuitive, since UTF comes from the database, and UTF leaves in response. Applications generally work with characters, not bytes.
In this case, bytes are required only due to the fact that inside the validator to check uniqueness, md5 is used, which needs bytes, it is not logical to convert all data due to the internal implementation in the library.
In addition, this conversion can lead to undefined behavior and significantly affect performance.
It can also break pattern-based string validation and string lengths elsewhere.
I'm going to close this issue, since there haven't been any updates for a year.
Steps to reproduce the behavior
Add an array with string unique items to the specification ("uniqueItems": true)
and validate non-ASCII values
Expected behavior
No errors
Actual behavior
Wide character in subroutine entry at /home/crux/workspace/qq/core/lib/JSON/Validator/Util.pm line 27.
Apparently the error occurs because the Mojo::Util::md5_sum is expecting bytes here:
While stuck in a local dirty hotfix: