0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-24 09:11:52 +00:00
htmlpurifier/library/HTMLPurifier/AttrDef/Integer.php
Edward Z. Yang 71c4a3c50c Commit dud AttrDef integer.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@235 48356398-32a2-884e-a903-53898d9a118a
2006-08-13 21:59:52 +00:00

37 lines
953 B
PHP

<?php
require_once 'HTMLPurifier/AttrDef.php';
// appears to be a dud class: no currently allowed CSS uses this type
// Uses this: widows, orphans, z-index, counter-increment, counter-reset
class HTMLPurifier_AttrDef_Integer extends HTMLPurifier_AttrDef
{
var $non_negative = false;
function HTMLPurifier_AttrDef_Integer($non_negative = false) {
$this->non_negative = $non_negative;
}
function validate($integer, $config, &$context) {
$integer = $this->parseCDATA($integer);
if ($integer === '') return false;
if ( !$this->non_negative && $integer[0] === '-' ) {
$digits = substr($integer, 1);
} elseif( $integer[0] === '+' ) {
$digits = $integer = substr($integer, 1);
} else {
$digits = $integer;
}
if (!ctype_digit($digits)) return false;
return $integer;
}
}
?>