mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 08:21:52 +00:00
PHP 8.1: fix various deprecations/errors in newest version of PHP (#310)
* Test on PHP 8.1 * PHP 8.1: fix deprecated NULL param to glob() * PHP 8.1: fix PHP error when passing NULL to rawurlencode() * PHP 8.1: calling ctype_lower with FALSE is deprecated * PHP 8.1: passing NULL to setAttribute() is deprecated * PHP 8.1: passing NULL to str_replace() is an error * PHP 8.1: fix error passing NULL to str_replace() * PHP 8.1: fix return type deprecation with backwards compatible attribute * Revert typo
This commit is contained in:
parent
12ab42bd6e
commit
1dd3e52365
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
php: [5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0]
|
php: [5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1]
|
||||||
|
|
||||||
name: PHP ${{ matrix.php }}
|
name: PHP ${{ matrix.php }}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ class FSTools
|
|||||||
/**
|
/**
|
||||||
* Recursively globs a directory.
|
* Recursively globs a directory.
|
||||||
*/
|
*/
|
||||||
public function globr($dir, $pattern, $flags = NULL)
|
public function globr($dir, $pattern, $flags = 0)
|
||||||
{
|
{
|
||||||
$files = $this->glob("$dir/$pattern", $flags);
|
$files = $this->glob("$dir/$pattern", $flags);
|
||||||
if ($files === false) $files = array();
|
if ($files === false) $files = array();
|
||||||
|
@ -176,7 +176,7 @@ class HTMLPurifier_ElementDef
|
|||||||
|
|
||||||
if (!empty($def->content_model)) {
|
if (!empty($def->content_model)) {
|
||||||
$this->content_model =
|
$this->content_model =
|
||||||
str_replace("#SUPER", $this->content_model, $def->content_model);
|
str_replace("#SUPER", (string)$this->content_model, $def->content_model);
|
||||||
$this->child = false;
|
$this->child = false;
|
||||||
}
|
}
|
||||||
if (!empty($def->content_model_type)) {
|
if (!empty($def->content_model_type)) {
|
||||||
|
@ -78,7 +78,7 @@ class HTMLPurifier_Length
|
|||||||
if ($this->n === '0' && $this->unit === false) {
|
if ($this->n === '0' && $this->unit === false) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!ctype_lower($this->unit)) {
|
if ($this->unit === false || !ctype_lower($this->unit)) {
|
||||||
$this->unit = strtolower($this->unit);
|
$this->unit = strtolower($this->unit);
|
||||||
}
|
}
|
||||||
if (!isset(HTMLPurifier_Length::$allowedUnits[$this->unit])) {
|
if (!isset(HTMLPurifier_Length::$allowedUnits[$this->unit])) {
|
||||||
|
@ -306,8 +306,8 @@ class HTMLPurifier_Lexer
|
|||||||
{
|
{
|
||||||
// normalize newlines to \n
|
// normalize newlines to \n
|
||||||
if ($config->get('Core.NormalizeNewlines')) {
|
if ($config->get('Core.NormalizeNewlines')) {
|
||||||
$html = str_replace("\r\n", "\n", $html);
|
$html = str_replace("\r\n", "\n", (string)$html);
|
||||||
$html = str_replace("\r", "\n", $html);
|
$html = str_replace("\r", "\n", (string)$html);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config->get('HTML.Trusted')) {
|
if ($config->get('HTML.Trusted')) {
|
||||||
|
@ -4410,7 +4410,7 @@ class HTML5TreeConstructer
|
|||||||
|
|
||||||
foreach ($token['attr'] as $attr) {
|
foreach ($token['attr'] as $attr) {
|
||||||
if (!$el->hasAttribute($attr['name'])) {
|
if (!$el->hasAttribute($attr['name'])) {
|
||||||
$el->setAttribute($attr['name'], $attr['value']);
|
$el->setAttribute($attr['name'], (string)$attr['value']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ class HTMLPurifier_PropertyListIterator extends FilterIterator
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function accept()
|
public function accept()
|
||||||
{
|
{
|
||||||
$key = $this->getInnerIterator()->key();
|
$key = $this->getInnerIterator()->key();
|
||||||
|
@ -20,6 +20,7 @@ class HTMLPurifier_StringHash extends ArrayObject
|
|||||||
* @param mixed $index
|
* @param mixed $index
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function offsetGet($index)
|
public function offsetGet($index)
|
||||||
{
|
{
|
||||||
$this->accessed[$index] = true;
|
$this->accessed[$index] = true;
|
||||||
|
@ -100,11 +100,11 @@ class HTMLPurifier_URIFilter_Munge extends HTMLPurifier_URIFilter
|
|||||||
$string = $uri->toString();
|
$string = $uri->toString();
|
||||||
// always available
|
// always available
|
||||||
$this->replace['%s'] = $string;
|
$this->replace['%s'] = $string;
|
||||||
$this->replace['%r'] = $context->get('EmbeddedURI', true);
|
$this->replace['%r'] = $context->get('EmbeddedURI', true) ?: '';
|
||||||
$token = $context->get('CurrentToken', true);
|
$token = $context->get('CurrentToken', true) ?: '';
|
||||||
$this->replace['%n'] = $token ? $token->name : null;
|
$this->replace['%n'] = $token ? $token->name : '';
|
||||||
$this->replace['%m'] = $context->get('CurrentAttr', true);
|
$this->replace['%m'] = $context->get('CurrentAttr', true) ?: '';
|
||||||
$this->replace['%p'] = $context->get('CurrentCSSProperty', true);
|
$this->replace['%p'] = $context->get('CurrentCSSProperty', true) ?: '';
|
||||||
// not always available
|
// not always available
|
||||||
if ($this->secretKey) {
|
if ($this->secretKey) {
|
||||||
$this->replace['%t'] = hash_hmac("sha256", $string, $this->secretKey);
|
$this->replace['%t'] = hash_hmac("sha256", $string, $this->secretKey);
|
||||||
|
Loading…
Reference in New Issue
Block a user