Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4184741
BlockedDomainValidator.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
903 B
Referenced Files
None
Subscribers
None
BlockedDomainValidator.php
View Options
<?php
namespace
MediaWiki\Extension\AbuseFilter\BlockedDomains
;
use
MediaWiki\Utils\UrlUtils
;
class
BlockedDomainValidator
{
public
const
SERVICE_NAME
=
'AbuseFilterBlockedDomainValidator'
;
private
UrlUtils
$urlUtils
;
public
function
__construct
(
UrlUtils
$urlUtils
)
{
$this
->
urlUtils
=
$urlUtils
;
}
/**
* Validate an input domain
*
* @param string|null $domain Domain such as foo.wikipedia.org
* @return string|false Parsed domain, or false otherwise
*/
public
function
validateDomain
(
?
string
$domain
)
{
if
(
!
$domain
)
{
return
false
;
}
$domain
=
trim
(
$domain
);
if
(
!
str_contains
(
$domain
,
'//'
)
)
{
$domain
=
'https://'
.
$domain
;
}
$parsedUrl
=
$this
->
urlUtils
->
parse
(
$domain
);
// Parse url returns a valid URL for "foo"
if
(
!
$parsedUrl
||
!
str_contains
(
$parsedUrl
[
'host'
],
'.'
)
)
{
return
false
;
}
return
$parsedUrl
[
'host'
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 20 2026, 14:46 (11 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4e/af/e97aff9cf4ef212c447193b4d4f2
Default Alt Text
BlockedDomainValidator.php (903 B)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment