mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-14 17:28:40 +00:00
37 lines
953 B
PHP
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;
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
?>
|