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

changing the mb_strlen to strlen #16643

Merged
merged 5 commits into from
Sep 4, 2024
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
10 changes: 10 additions & 0 deletions CHANGELOG-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

- Changed `Phalcon\Filter\Validation\Validator\Email` to allow UTF8 in local part. [#16637](https://github.com/phalcon/cphalcon/issues/16637)

### Added


### Fixed

- Fixed `Phalcon\Encryption\Crypt` to use `strlen` instead of `mb_strlen` for padding calculations [#16642](https://github.com/phalcon/cphalcon/issues/16642)

### Removed


## [5.8.0](https://github.com/phalcon/cphalcon/releases/tag/v5.8.0) (2024-07-09)

### Changed
Expand Down
338 changes: 173 additions & 165 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions phalcon/Encryption/Crypt.zep
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ class Crypt implements CryptInterface
return false;
}

return length <= mb_strlen(input);
return length <= strlen(input);
}

/**
Expand Down Expand Up @@ -633,7 +633,7 @@ class Crypt implements CryptInterface
paddingSize = 0;

if true === this->checkIsMode(["cbc", "ecb"], mode) {
let paddingSize = blockSize - (mb_strlen(input) % blockSize);
let paddingSize = blockSize - (strlen(input) % blockSize);

if paddingSize >= 256 || paddingSize < 0 {
throw new Exception(
Expand Down
8 changes: 4 additions & 4 deletions phalcon/Filter/Validation/Validator/StringLength/Max.zep
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Max extends AbstractValidator
*/
public function validate(<Validation> validation, var field) -> bool
{
var value, length, maximum, replacePairs, included, result;
var failed, included, length, maximum, replacePairs, value;

let value = validation->getValue(field);
if this->allowEmpty(field, value) {
Expand Down Expand Up @@ -115,12 +115,12 @@ class Max extends AbstractValidator
}

if included {
let result = length >= maximum;
let failed = length > maximum;
} else {
let result = length > maximum;
let failed = length >= maximum;
}

if result {
if failed {
let replacePairs = [
":max" : maximum
];
Expand Down
8 changes: 4 additions & 4 deletions phalcon/Filter/Validation/Validator/StringLength/Min.zep
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Min extends AbstractValidator
*/
public function validate(<Validation> validation, var field) -> bool
{
var value, length, minimum, replacePairs, included, result;
var failed, included, length, minimum, replacePairs, value;

let value = validation->getValue(field);
if this->allowEmpty(field, value) {
Expand Down Expand Up @@ -115,12 +115,12 @@ class Min extends AbstractValidator
}

if included {
let result = length <= minimum;
let failed = length < minimum;
} else {
let result = length < minimum;
let failed = length <= minimum;
}

if result {
if failed {
let replacePairs = [
":min" : minimum
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function filterValidationValidatorCallbackValidateSingleFieldValidator(In

$messages = $validation->validate(
[
'user' => 'user',
'user' => '12345',
'admin' => null,
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,23 @@ public function filterValidationValidatorMaxStringLengthValidateSingleField(Inte

$messages = $validation->validate(
[
'name' => 'SomeValue',
'name' => '12345678',
]
);

$I->assertSame(
0,
$messages->count()
);

$expected = 0;
$actual = $messages->count();
$I->assertSame($expected, $actual);

$messages = $validation->validate(
[
'name' => 'SomeValue123',
'name' => '123456789',
]
);

$I->assertSame(
1,
$messages->count()
);
$expected = 1;
$actual = $messages->count();
$I->assertSame($expected, $actual);
}

/**
Expand Down Expand Up @@ -120,36 +117,32 @@ public function filterValidationValidatorMaxOrEqualStringLengthValidateSingleFie

$messages = $validation->validate(
[
'name' => 'short',
'name' => '12345',
]
);

$I->assertSame(
0,
$messages->count()
);
$expected = 0;
$actual = $messages->count();
$I->assertSame($expected, $actual);

$messages = $validation->validate(
[
'name' => 'SomeValue',
'name' => '1234567890',
]
);

$I->assertSame(
1,
$messages->count()
);

$expected = 1;
$actual = $messages->count();
$I->assertSame($expected, $actual);

$messages = $validation->validate(
[
'name' => 'SomeValue123',
]
);

$I->assertSame(
1,
$messages->count()
);
$expected = 1;
$actual = $messages->count();
$I->assertSame($expected, $actual);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public function filterValidationValidatorMinValidateEmpty(IntegrationTester $I)
$entity->name = '';

$validation->bind($entity, []);
$result = $validator->validate($validation, 'name');
$I->assertTrue($result);
$actual = $validator->validate($validation, 'name');
$I->assertTrue($actual);
}

/**
Expand All @@ -69,29 +69,26 @@ public function filterValidationValidatorMinStringLengthValidateSingleField(Inte
)
);


$messages = $validation->validate(
[
'name' => 'SomeValue',
'name' => '1234567890',
]
);

$I->assertSame(
0,
$messages->count()
);
$expected = 0;
$actual = $messages->count();
$I->assertSame($expected, $actual);


$messages = $validation->validate(
[
'name' => 'SomeValue123',
'name' => '123456789',
]
);

$I->assertSame(
0,
$messages->count()
);
$expected = 1;
$actual = $messages->count();
$I->assertSame($expected, $actual);
}

/**
Expand Down Expand Up @@ -120,25 +117,23 @@ public function filterValidationValidatorMinOrEqualStringLengthValidateSingleFie

$messages = $validation->validate(
[
'name' => 'SomeValue',
'name' => '12345678',
]
);

$I->assertSame(
1,
$messages->count()
);
$expected = 1;
$actual = $messages->count();
$I->assertSame($expected, $actual);


$messages = $validation->validate(
[
'name' => 'SomeValue123',
'name' => '1234567890',
]
);

$I->assertSame(
0,
$messages->count()
);
$expected = 0;
$actual = $messages->count();
$I->assertSame($expected, $actual);
}
}
Loading
Loading