PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Validate » Validate » Bug #3125

inval() breaks Validation zero-padded SSN

Details

Submitted2005-01-06 19:55 UTC
Frommemeyou at memeyou dot net
Assigneddufuz
StatusClosed
PackageValidate
PHP Version5.0.2
OSLinux
Roadmaps(Not assigned)

Comments

[2005-01-06 19:55 UTC] memeyou at memeyou dot net

Description:
------------
The intval breaks SSN parts that lead with zero/s. I simply removed them. The is_numeric should be enough for validation.

Validate/US.php

--- US.php.orig 2005-01-06 09:44:12.653634992 -1000
+++ US.php 2005-01-06 09:37:59.958293296 -1000
@@ -42,9 +42,9 @@
if (!is_numeric($ssn) || !(strlen($ssn) == 9)) {
return false;
}
- $area = intval(substr($ssn, 0, 3));
- $group = intval(substr($ssn, 3, 2));
- $serial = intval(substr($ssn, 5, 4));
+ $area = substr($ssn, 0, 3);
+ $group = substr($ssn, 3, 2);
+ $serial = substr($ssn, 5, 4);

if (!$high_groups) {
$high_groups = Validate_US::ssnGetHighGroups();

[2005-01-07 22:53 UTC] memeyou at memeyou dot net

http://www.ssa.gov/employer/highgroup.txt, which is in US.php, has a list of prefixes (first 3 digits) and how many thousands it is limited to (next two digits). Make up any number within these contraints and the last 4 digits can be anything. For example, 001000000. Mahalo, Tom

[2005-01-10 22:11 UTC] memeyou at memeyou dot net

well, 097469490 should be true as there is

[2005-01-10 22:13 UTC] memeyou at memeyou dot net

opps, 097469490 should be true since 097 92 exists. But 001423000 shouldn't. I'll guess we are not checking the group numbers.

[2005-01-10 22:21 UTC] memeyou at memeyou dot net

My bad, we need the intval on the groups. this patch only remove intval on area, which is what needs the exact match.

--- US.php.orig 2005-01-10 12:20:03.937084048 -1000
+++ US.php 2005-01-10 12:19:25.327953528 -1000
@@ -42,7 +42,7 @@
if (!is_numeric($ssn) || !(strlen($ssn) == 9)) {
return false;
}
- $area = intval(substr($ssn, 0, 3));
+ $area = substr($ssn, 0, 3);
$group = intval(substr($ssn, 3, 2));
$serial = intval(substr($ssn, 5, 4));

[2005-01-10 23:21 UTC] memeyou at memeyou dot net

That's fine by me. I don't think the last four digits can be all zero, anyway. At least, I've never seen any.

[2005-01-10 23:26 UTC] memeyou at memeyou dot net

FYI, http://www.ssa.gov/employer/ssnweb.htm says:

The Social Security number consists of nine (9) digits. The first three (3) digits denote the area (or State) where the application for an original Social Security number was filed.

Within each area, the group number (middle two (2) digits) range from 01 to 99 but are not assigned in consecutive order. For administrative reasons, group numbers issued first consist of the ODD numbers from 01 through 09 and then EVEN numbers from 10 through 98, within each area number allocated to a State. After all numbers in group 98 of a particular area have been issued, the EVEN Groups 02 through 08 are used, followed by ODD Groups 11 through 99.

Within each group, the serial numbers (last four (4) digits) run consecutively from 0001 through 9999.

[2005-01-11 01:23 UTC] memeyou at memeyou dot net

This is the desired behavior, because of the order they are assigned:

Odds 1 to 9: 01,03,05,07,09 then
Evens 10 to 98: 10, 12, 14..98 then
Evens 2 to 10: 02, 04, 06, 08 then
Odds 11 to 99: 11, 13, 15..99.

so if the HIGH GROUP is 42, 41 is not valid a valid group, since the ODDs 11-99 are last and have not been reached yet.