Skip to content

Commit f6319f1

Browse files
committed
#16477 - Add digits check
1 parent a36c7d8 commit f6319f1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

phalcon/Filter/Validation/Validator/CreditCard.zep

+7-4
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,15 @@ class CreditCard extends AbstractValidator
9797
*/
9898
private function verifyByLuhnAlgorithm(string number) -> bool
9999
{
100-
var digit, position, hash = "", result;
101-
array digits;
100+
var digit, digits, position, hash = "", result;
102101

103-
let digits = (array) str_split(number);
102+
if (ctype_digit(number) === false) {
103+
return false;
104+
}
105+
106+
let digits = array_reverse(str_split(number));
104107

105-
for position, digit in digits->reversed() {
108+
for position, digit in digits {
106109
let hash .= (position % 2 ? digit * 2 : digit);
107110
}
108111

0 commit comments

Comments
 (0)