Commit f8a47719 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Sanatize.php: Sanatize constants renamed

parent 7485b573
......@@ -32,19 +32,19 @@ class Sanatize {
switch ($sanatizeClass) {
case SANATIZE_DEFAULT:
case SANATIZE_DIGIT:
if (!is_numeric($value)) {
case SANATIZE_ALLOW_DIGIT:
if (!is_numeric($value)) {
$value = '';
}
}
break;
case SANATIZE_ALNUMX:
case SANATIZE_ALLOW_ALNUMX:
// replace ALNUMX valid characters, which are not part of ctype_alnum, by valid ctype_alnum characters, to fake ctype_alnum
if (!ctype_alnum(str_replace(array('@', '-', '_', '.', ',', ';'), 'a', $value)))
$value = '';
break;
case SANATIZE_ALL:
case SANATIZE_ALLOW_ALL:
break;
default:
......
......@@ -23,30 +23,30 @@ class SanatizeTest extends \PHPUnit_Framework_TestCase {
# Access are cached: use new variables for every test.
# Check '1'
$this->assertEquals('1', Sanatize::sanatize('1', SANATIZE_DIGIT), "SANATIZE_DIGIT fails");
$this->assertEquals('1', Sanatize::sanatize('1', SANATIZE_ALNUMX), "SANATIZE_ALNUMX fails");
$this->assertEquals('1', Sanatize::sanatize('1', SANATIZE_ALL), "SANATIZE_ALL fails");
$this->assertEquals('1', Sanatize::sanatize('1', SANATIZE_ALLOW_DIGIT), "SANATIZE_DIGIT fails");
$this->assertEquals('1', Sanatize::sanatize('1', SANATIZE_ALLOW_ALNUMX), "SANATIZE_ALNUMX fails");
$this->assertEquals('1', Sanatize::sanatize('1', SANATIZE_ALLOW_ALL), "SANATIZE_ALL fails");
# Check '-3'
$this->assertEquals('-3', Sanatize::sanatize('-3', SANATIZE_DIGIT), "SANATIZE_DIGIT fails");
$this->assertEquals('-3', Sanatize::sanatize('-3', SANATIZE_ALNUMX), "SANATIZE_ALNUMX fails");
$this->assertEquals('-3', Sanatize::sanatize('-3', SANATIZE_ALL), "SANATIZE_ALL fails");
$this->assertEquals('-3', Sanatize::sanatize('-3', SANATIZE_ALLOW_DIGIT), "SANATIZE_DIGIT fails");
$this->assertEquals('-3', Sanatize::sanatize('-3', SANATIZE_ALLOW_ALNUMX), "SANATIZE_ALNUMX fails");
$this->assertEquals('-3', Sanatize::sanatize('-3', SANATIZE_ALLOW_ALL), "SANATIZE_ALL fails");
# Check 'a'
$this->assertEquals('', Sanatize::sanatize('a', SANATIZE_DIGIT), "SANATIZE_DIGIT fails");
$this->assertEquals('a', Sanatize::sanatize('a', SANATIZE_ALNUMX), "SANATIZE_ALNUMX fails");
$this->assertEquals('a', Sanatize::sanatize('a', SANATIZE_ALL), "SANATIZE_ALL fails");
$this->assertEquals('', Sanatize::sanatize('a', SANATIZE_ALLOW_DIGIT), "SANATIZE_DIGIT fails");
$this->assertEquals('a', Sanatize::sanatize('a', SANATIZE_ALLOW_ALNUMX), "SANATIZE_ALNUMX fails");
$this->assertEquals('a', Sanatize::sanatize('a', SANATIZE_ALLOW_ALL), "SANATIZE_ALL fails");
# Check 'a@-_.,;Z09'
$this->assertEquals('', Sanatize::sanatize('a@-_.,;Z09', SANATIZE_DIGIT), "SANATIZE_DIGIT fails");
$this->assertEquals('a@-_.,;Z09', Sanatize::sanatize('a@-_.,;Z09', SANATIZE_ALNUMX), "SANATIZE_ALNUMX fails");
$this->assertEquals('a@-_.,;Z09', Sanatize::sanatize('a@-_.,;Z09', SANATIZE_ALL), "SANATIZE_ALL fails");
$this->assertEquals('', Sanatize::sanatize('a@-_.,;Z09', SANATIZE_ALLOW_DIGIT), "SANATIZE_DIGIT fails");
$this->assertEquals('a@-_.,;Z09', Sanatize::sanatize('a@-_.,;Z09', SANATIZE_ALLOW_ALNUMX), "SANATIZE_ALNUMX fails");
$this->assertEquals('a@-_.,;Z09', Sanatize::sanatize('a@-_.,;Z09', SANATIZE_ALLOW_ALL), "SANATIZE_ALL fails");
# Check 'a+Z09'
$this->assertEquals('', Sanatize::sanatize('a+Z09', SANATIZE_DIGIT), "SANATIZE_DIGIT fails");
$this->assertEquals('', Sanatize::sanatize('a+Z09', SANATIZE_ALNUMX), "SANATIZE_ALNUMX fails");
$this->assertEquals('a+Z09', Sanatize::sanatize('a+Z09', SANATIZE_ALL), "SANATIZE_ALL fails");
$this->assertEquals('', Sanatize::sanatize('a+Z09', SANATIZE_ALLOW_DIGIT), "SANATIZE_DIGIT fails");
$this->assertEquals('', Sanatize::sanatize('a+Z09', SANATIZE_ALLOW_ALNUMX), "SANATIZE_ALNUMX fails");
$this->assertEquals('a+Z09', Sanatize::sanatize('a+Z09', SANATIZE_ALLOW_ALL), "SANATIZE_ALL fails");
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment