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