zendframework / zend-validator

Validator component from Zend Framework
BSD 3-Clause "New" or "Revised" License
181 stars 136 forks source link

Correcting validation error #231

Closed adamoki closed 4 years ago

adamoki commented 6 years ago

Sometimes there is a problem with validation - when generated hash is valid integer (includes only digits - it rarely happens) - php converts that string to integer - then you get integer in array of hashes ($hashes). Comparing that integer to returned string from hash_file function results in false value while hash is the same but differs in variable type.

weierophinney commented 5 years ago

We definitely need a unit test for this before we can merge. The unit test should fail under current master, and pass after the patch is applied.

I tend to agree with @webimpress - we should be casting hashes to strings when calling setHash() and/or in the constructor.

michalbundyra commented 4 years ago

@weierophinney I've pushed changes to this branch. I am checking now if input hash is string, and if not I am throwing an exception. We do have that check when we provide just a hash, without algorithm, but with algorithm we haven't had this check. Please see test I've added.

@adamoki Are you satisfied with the solution I've provided?

michalbundyra commented 4 years ago

Thanks, @adamoki!