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

T15992 validation length #15995

Merged
merged 2 commits into from
Jun 15, 2022
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
7 changes: 7 additions & 0 deletions CHANGELOG-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Fixed
- Fixed `Phalcon\Tag::textArea()` to check if the value is `null` before calling `htmlspecialchars` [#15992](https://github.com/phalcon/cphalcon/issues/15992)
- Fixed
- `Phalcon/Filter/Validation/Validator/Alnum`
`Phalcon/Filter/Validation/Validator/Alpha`
`Phalcon/Filter/Validation/Validator/Confirmation`
`Phalcon/Filter/Validation/Validator/CreditCard`
`Phalcon/Filter/Validation/Validator/StringLength/Max`
`Phalcon/Filter/Validation/Validator/StringLength/Min` to check if the value is `null` before calling internal PHP methods [#15992](https://github.com/phalcon/cphalcon/issues/15992)

## Added
- Added support for `webp` images for `Phalcon\Image\Adapter\Gd` [#15977](https://github.com/phalcon/cphalcon/issues/15977)
Expand Down
2 changes: 1 addition & 1 deletion phalcon/Filter/Validation/Validator/Alnum.zep
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Alnum extends AbstractValidator
return true;
}

if !ctype_alnum(value) {
if !ctype_alnum((string) value) {
validation->appendMessage(
this->messageFactory(validation, field)
);
Expand Down
2 changes: 1 addition & 1 deletion phalcon/Filter/Validation/Validator/Alpha.zep
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Alpha extends AbstractValidator
return true;
}

if preg_match("/[^[:alpha:]]/imu", value) {
if preg_match("/[^[:alpha:]]/imu", (string) value) {
validation->appendMessage(
this->messageFactory(validation, field)
);
Expand Down
2 changes: 1 addition & 1 deletion phalcon/Filter/Validation/Validator/Confirmation.zep
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Confirmation extends AbstractValidator
let value = validation->getValue(field),
valueWith = validation->getValue(fieldWith);

if !this->compare(value, valueWith) {
if !this->compare((string) value, (string) valueWith) {
let labelWith = this->getOption("labelWith");

if typeof labelWith == "array" {
Expand Down
2 changes: 1 addition & 1 deletion phalcon/Filter/Validation/Validator/CreditCard.zep
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class CreditCard extends AbstractValidator
return true;
}

let valid = this->verifyByLuhnAlgorithm(value);
let valid = this->verifyByLuhnAlgorithm((string) value);

if !valid {
validation->appendMessage(
Expand Down
4 changes: 2 additions & 2 deletions phalcon/Filter/Validation/Validator/StringLength/Max.zep
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ class Max extends AbstractValidator

// Check if mbstring is available to calculate the correct length
if function_exists("mb_strlen") {
let length = mb_strlen(value);
let length = mb_strlen((string) value);
} else {
let length = strlen(value);
let length = strlen((string) value);
}

let maximum = this->getOption("max");
Expand Down
4 changes: 2 additions & 2 deletions phalcon/Filter/Validation/Validator/StringLength/Min.zep
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ class Min extends AbstractValidator

// Check if mbstring is available to calculate the correct length
if function_exists("mb_strlen") {
let length = mb_strlen(value);
let length = mb_strlen((string) value);
} else {
let length = strlen(value);
let length = strlen((string) value);
}

let minimum = this->getOption("min");
Expand Down