0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-22 08:21:52 +00:00

Fix #322 - PHP 8.1 deprecation notice in HostBlacklist URIFilter (#323)

This commit is contained in:
Kieran 2022-06-27 22:20:36 +01:00 committed by GitHub
parent 1db36fb09d
commit 3fc193c755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -35,7 +35,7 @@ class HTMLPurifier_URIFilter_HostBlacklist extends HTMLPurifier_URIFilter
public function filter(&$uri, $config, $context)
{
foreach ($this->blacklist as $blacklisted_host_fragment) {
if (strpos($uri->host, $blacklisted_host_fragment) !== false) {
if ($uri->host !== null && strpos($uri->host, $blacklisted_host_fragment) !== false) {
return false;
}
}

View File

@ -28,6 +28,12 @@ class HTMLPurifier_URIFilter_HostBlacklistTest extends HTMLPurifier_URIFilterHar
$this->assertFiltering('http://google.com');
}
public function testFragment()
{
$this->config->set('URI.HostBlacklist', 'example.com');
$this->assertFiltering('#foo');
}
}
// vim: et sw=4 sts=4