diff --git a/library/HTMLPurifier/URISchemeRegistry.php b/library/HTMLPurifier/URISchemeRegistry.php
index 4ac8a0b7..1e3229ae 100644
--- a/library/HTMLPurifier/URISchemeRegistry.php
+++ b/library/HTMLPurifier/URISchemeRegistry.php
@@ -40,6 +40,12 @@ public static function instance($prototype = null)
*/
public function getScheme($scheme, $config, $context)
{
+ // Prevent deprecated "null used as array offset" in PHP 8.1+.
+ // A null scheme indicates "no scheme", so return early.
+ if ($scheme === null) {
+ return;
+ }
+
if (!$config) {
$config = HTMLPurifier_Config::createDefault();
}