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

fix #15252 - compare 000012345 and 12345 #15347

Merged
merged 1 commit into from
Mar 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
## Fixed
- Fixed `Phalcon\Mvc\Model::average()` to return `float` value when is `string` [#15287](https://github.com/phalcon/cphalcon/pull/15287)
- Fixed `Phalcon\Storage\Serializer\Igbinary` to store `is_numeric` and `bool` values properly [#15240](https://github.com/phalcon/cphalcon/pull/15240)
- Fixed `Phalcon\Validation\Validator\Confirmation` was failing to compare cases such as 000123 = 123 [#15347](https://github.com/phalcon/cphalcon/pull/15347)
2 changes: 1 addition & 1 deletion phalcon/Validation/Validator/Confirmation.zep
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ class Confirmation extends AbstractValidator
let b = mb_strtolower(b, "utf-8");
}

return a == b;
return strcmp($a, $b) === 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
*/
class ValidateCest
{

/**
* Tests Phalcon\Validation\Validator\Confirmation :: validate() - single
* field
*
* @author Wojciech Ślawski <jurigag@gmail.com>
* @param IntegrationTester $I
*
* @since 2016-06-05
* @author Wojciech Ślawski <jurigag@gmail.com>
*/
public function validationValidatorConfirmationValidateSingleField(IntegrationTester $I)
{
Expand Down Expand Up @@ -73,14 +76,44 @@ public function validationValidatorConfirmationValidateSingleField(IntegrationTe
1,
$messages->count()
);


// https://github.com/phalcon/cphalcon/issues/15252
$messages = $validation->validate(
[
'name' => '000012345',
'nameWith' => '12345',
]
);

$I->assertEquals(
1,
$messages->count(),
"Phalcon\Validation\Validator\Confirmation failed to compare 000012345=12345"
);

$messages = $validation->validate(
[
'name' => 'asd',
'nameWith' => 'asdß',
]
);

$I->assertEquals(
1,
$messages->count(),
"Phalcon\Validation\Validator\Confirmation failed to compare asd=asdß"
);
}

/**
* Tests Phalcon\Validation\Validator\Confirmation :: validate() - multiple
* field
*
* @author Wojciech Ślawski <jurigag@gmail.com>
* @param IntegrationTester $I
*
* @since 2016-06-05
* @author Wojciech Ślawski <jurigag@gmail.com>
*/
public function validationValidatorConfirmationValidateMultipleField(IntegrationTester $I)
{
Expand Down Expand Up @@ -173,8 +206,10 @@ public function validationValidatorConfirmationValidateMultipleField(Integration
* Tests Phalcon\Validation\Validator\Confirmation :: validate() - empty
* value
*
* @author Stanislav Kiryukhin <korsar.zn@gmail.com>
* @param IntegrationTester $I
*
* @since 2015-09-06
* @author Stanislav Kiryukhin <korsar.zn@gmail.com>
*/
public function validationValidatorConfirmationValidateEmptyValues(IntegrationTester $I)
{
Expand Down