From 6d6d88512a8146939a9161bb03e95e3e97840439 Mon Sep 17 00:00:00 2001 From: John Flatness Date: Thu, 28 Dec 2017 02:02:09 -0500 Subject: [PATCH] Skip counting currentNesting if null This is an error starting in PHP 7.2 --- library/HTMLPurifier/Injector.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/HTMLPurifier/Injector.php b/library/HTMLPurifier/Injector.php index 5060eef9..116b470c 100644 --- a/library/HTMLPurifier/Injector.php +++ b/library/HTMLPurifier/Injector.php @@ -157,11 +157,13 @@ abstract class HTMLPurifier_Injector return false; } // check for exclusion - for ($i = count($this->currentNesting) - 2; $i >= 0; $i--) { - $node = $this->currentNesting[$i]; - $def = $this->htmlDefinition->info[$node->name]; - if (isset($def->excludes[$name])) { - return false; + if (!empty($this->currentNesting)) { + for ($i = count($this->currentNesting) - 2; $i >= 0; $i--) { + $node = $this->currentNesting[$i]; + $def = $this->htmlDefinition->info[$node->name]; + if (isset($def->excludes[$name])) { + return false; + } } } return true;