mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 08:21:52 +00:00
Fixed reserved words in constants for PHP 7 as per https://www.php.net/manual/en/reserved.other-reserved-words.php (#222)
This commit is contained in:
parent
a93250f251
commit
f03e1a2c48
@ -48,7 +48,7 @@ class HTMLPurifier_Printer_ConfigForm extends HTMLPurifier_Printer
|
||||
$this->compress = $compress;
|
||||
// initialize sub-printers
|
||||
$this->fields[0] = new HTMLPurifier_Printer_ConfigForm_default();
|
||||
$this->fields[HTMLPurifier_VarParser::BOOL] = new HTMLPurifier_Printer_ConfigForm_bool();
|
||||
$this->fields[HTMLPurifier_VarParser::C_BOOL] = new HTMLPurifier_Printer_ConfigForm_bool();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -339,7 +339,7 @@ class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer
|
||||
$value = '';
|
||||
}
|
||||
}
|
||||
if ($type === HTMLPurifier_VarParser::MIXED) {
|
||||
if ($type === HTMLPurifier_VarParser::C_MIXED) {
|
||||
return 'Not supported';
|
||||
$value = serialize($value);
|
||||
}
|
||||
|
@ -7,34 +7,34 @@
|
||||
class HTMLPurifier_VarParser
|
||||
{
|
||||
|
||||
const STRING = 1;
|
||||
const C_STRING = 1;
|
||||
const ISTRING = 2;
|
||||
const TEXT = 3;
|
||||
const ITEXT = 4;
|
||||
const INT = 5;
|
||||
const FLOAT = 6;
|
||||
const BOOL = 7;
|
||||
const C_INT = 5;
|
||||
const C_FLOAT = 6;
|
||||
const C_BOOL = 7;
|
||||
const LOOKUP = 8;
|
||||
const ALIST = 9;
|
||||
const HASH = 10;
|
||||
const MIXED = 11;
|
||||
const C_MIXED = 11;
|
||||
|
||||
/**
|
||||
* Lookup table of allowed types. Mainly for backwards compatibility, but
|
||||
* also convenient for transforming string type names to the integer constants.
|
||||
*/
|
||||
public static $types = array(
|
||||
'string' => self::STRING,
|
||||
'string' => self::C_STRING,
|
||||
'istring' => self::ISTRING,
|
||||
'text' => self::TEXT,
|
||||
'itext' => self::ITEXT,
|
||||
'int' => self::INT,
|
||||
'float' => self::FLOAT,
|
||||
'bool' => self::BOOL,
|
||||
'int' => self::C_INT,
|
||||
'float' => self::C_FLOAT,
|
||||
'bool' => self::C_BOOL,
|
||||
'lookup' => self::LOOKUP,
|
||||
'list' => self::ALIST,
|
||||
'hash' => self::HASH,
|
||||
'mixed' => self::MIXED
|
||||
'mixed' => self::C_MIXED
|
||||
);
|
||||
|
||||
/**
|
||||
@ -42,7 +42,7 @@ class HTMLPurifier_VarParser
|
||||
* allowed value lists.
|
||||
*/
|
||||
public static $stringTypes = array(
|
||||
self::STRING => true,
|
||||
self::C_STRING => true,
|
||||
self::ISTRING => true,
|
||||
self::TEXT => true,
|
||||
self::ITEXT => true,
|
||||
@ -74,7 +74,7 @@ class HTMLPurifier_VarParser
|
||||
// These are basic checks, to make sure nothing horribly wrong
|
||||
// happened in our implementations.
|
||||
switch ($type) {
|
||||
case (self::STRING):
|
||||
case (self::C_STRING):
|
||||
case (self::ISTRING):
|
||||
case (self::TEXT):
|
||||
case (self::ITEXT):
|
||||
@ -85,17 +85,17 @@ class HTMLPurifier_VarParser
|
||||
$var = strtolower($var);
|
||||
}
|
||||
return $var;
|
||||
case (self::INT):
|
||||
case (self::C_INT):
|
||||
if (!is_int($var)) {
|
||||
break;
|
||||
}
|
||||
return $var;
|
||||
case (self::FLOAT):
|
||||
case (self::C_FLOAT):
|
||||
if (!is_float($var)) {
|
||||
break;
|
||||
}
|
||||
return $var;
|
||||
case (self::BOOL):
|
||||
case (self::C_BOOL):
|
||||
if (!is_bool($var)) {
|
||||
break;
|
||||
}
|
||||
@ -119,7 +119,7 @@ class HTMLPurifier_VarParser
|
||||
}
|
||||
}
|
||||
return $var;
|
||||
case (self::MIXED):
|
||||
case (self::C_MIXED):
|
||||
return $var;
|
||||
default:
|
||||
$this->errorInconsistent(get_class($this), $type);
|
||||
|
@ -23,23 +23,23 @@ class HTMLPurifier_VarParser_Flexible extends HTMLPurifier_VarParser
|
||||
// Note: if code "breaks" from the switch, it triggers a generic
|
||||
// exception to be thrown. Specific errors can be specifically
|
||||
// done here.
|
||||
case self::MIXED:
|
||||
case self::C_MIXED:
|
||||
case self::ISTRING:
|
||||
case self::STRING:
|
||||
case self::C_STRING:
|
||||
case self::TEXT:
|
||||
case self::ITEXT:
|
||||
return $var;
|
||||
case self::INT:
|
||||
case self::C_INT:
|
||||
if (is_string($var) && ctype_digit($var)) {
|
||||
$var = (int)$var;
|
||||
}
|
||||
return $var;
|
||||
case self::FLOAT:
|
||||
case self::C_FLOAT:
|
||||
if ((is_string($var) && is_numeric($var)) || is_int($var)) {
|
||||
$var = (float)$var;
|
||||
}
|
||||
return $var;
|
||||
case self::BOOL:
|
||||
case self::C_BOOL:
|
||||
if (is_int($var) && ($var === 0 || $var === 1)) {
|
||||
$var = (bool)$var;
|
||||
} elseif (is_string($var)) {
|
||||
|
@ -15,12 +15,12 @@ class HTMLPurifier_ConfigSchemaTest extends HTMLPurifier_Harness
|
||||
$this->schema->add('Car.Seats', 5, 'int', false);
|
||||
|
||||
$this->assertIdentical($this->schema->defaults['Car.Seats'], 5);
|
||||
$this->assertIdentical($this->schema->info['Car.Seats']->type, HTMLPurifier_VarParser::INT);
|
||||
$this->assertIdentical($this->schema->info['Car.Seats']->type, HTMLPurifier_VarParser::C_INT);
|
||||
|
||||
$this->schema->add('Car.Age', null, 'int', true);
|
||||
|
||||
$this->assertIdentical($this->schema->defaults['Car.Age'], null);
|
||||
$this->assertIdentical($this->schema->info['Car.Age']->type, HTMLPurifier_VarParser::INT);
|
||||
$this->assertIdentical($this->schema->info['Car.Age']->type, HTMLPurifier_VarParser::C_INT);
|
||||
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ class HTMLPurifier_ConfigSchemaTest extends HTMLPurifier_Harness
|
||||
);
|
||||
|
||||
$this->assertIdentical($this->schema->defaults['QuantumNumber.Difficulty'], null);
|
||||
$this->assertIdentical($this->schema->info['QuantumNumber.Difficulty']->type, HTMLPurifier_VarParser::STRING);
|
||||
$this->assertIdentical($this->schema->info['QuantumNumber.Difficulty']->type, HTMLPurifier_VarParser::C_STRING);
|
||||
$this->assertIdentical($this->schema->info['QuantumNumber.Difficulty']->allow_null, true);
|
||||
$this->assertIdentical($this->schema->info['QuantumNumber.Difficulty']->allowed,
|
||||
array(
|
||||
@ -70,7 +70,7 @@ class HTMLPurifier_ConfigSchemaTest extends HTMLPurifier_Harness
|
||||
);
|
||||
|
||||
$this->assertIdentical($this->schema->defaults['Abbrev.HTH'], 'Happy to Help');
|
||||
$this->assertIdentical($this->schema->info['Abbrev.HTH']->type, HTMLPurifier_VarParser::STRING);
|
||||
$this->assertIdentical($this->schema->info['Abbrev.HTH']->type, HTMLPurifier_VarParser::C_STRING);
|
||||
$this->assertIdentical($this->schema->info['Abbrev.HTH']->allowed,
|
||||
array(
|
||||
'Happy to Help' => true,
|
||||
|
@ -53,7 +53,7 @@ class HTMLPurifier_VarParser_FlexibleTest extends HTMLPurifier_VarParserHarness
|
||||
|
||||
public function testValidate_withMagicNumbers()
|
||||
{
|
||||
$this->assertValid('foobar', HTMLPurifier_VarParser::STRING);
|
||||
$this->assertValid('foobar', HTMLPurifier_VarParser::C_STRING);
|
||||
}
|
||||
|
||||
public function testValidate_null()
|
||||
|
Loading…
Reference in New Issue
Block a user