Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

@@ -1,12 +1,11 @@
<?php
/**
* @brief Profanity Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 10 Nov 2016
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core;
@@ -379,59 +378,70 @@ class _Profanity extends \IPS\Patterns\ActiveRecord implements \JsonSerializable
$urls[] = "https://" . parse_url( \IPS\Settings::i()->base_url, PHP_URL_HOST ) . "/*";
}
try
if ( $urls )
{
/* Load the content so we can look for URL's */
$dom = new \IPS\Xml\DOMDocument;
$dom->loadHTML( $content );
/* Gather up all URL's */
$tags = $dom->getElementsByTagName('a');
$good = NULL;
foreach( $tags AS $tag )
try
{
if ( $tag->hasAttribute( 'href' ) and !$tag->hasAttribute( 'data-mentionid' ) )
/* Load the content so we can look for URL's */
$dom = new \IPS\Xml\DOMDocument;
$dom->loadHTML( $content );
/* Gather up all URL's */
$selector = new \DOMXPath($dom);
$tags = $selector->query('//img | //a');
$good = NULL;
foreach( $tags AS $tag )
{
if ( \IPS\Settings::i()->ipb_url_filter_option == 'none' )
if ( ( $tag->hasAttribute( 'href' ) and !$tag->hasAttribute( 'data-mentionid' ) ) OR $tag->hasAttribute( 'src' ) )
{
return TRUE;
}
foreach( $urls AS $url )
{
$url = preg_quote( $url, '/' );
$url = str_replace( '\*', "(.+?)", $url );
if ( \IPS\Settings::i()->ipb_url_filter_option == 'black' )
if ( \IPS\Settings::i()->ipb_url_filter_option == 'none' )
{
if ( preg_match( '/' . $url . '/i', $tag->getAttribute( 'href' ) ) )
{
return TRUE;
}
return TRUE;
}
else if ( \IPS\Settings::i()->ipb_url_filter_option == 'white' )
$urlToCheck = $tag->hasAttribute( 'href' ) ? $tag->getAttribute( 'href' ) : $tag->getAttribute( 'src' );
foreach( $urls AS $url )
{
if ( is_null( $good ) AND !preg_match( '/' . $url . '/i', $tag->getAttribute( 'href' ) ) )
/* Make sure we're not doing something weird like storing a blank URL */
if ( $url )
{
$good = FALSE;
break 2;
}
else
{
$good = TRUE;
break 2;
$url = preg_quote( $url, '/' );
$url = str_replace( '\*', "(.*?)", $url );
if ( \IPS\Settings::i()->ipb_url_filter_option == 'black' )
{
if ( preg_match( '/' . $url . '/i', $urlToCheck ) )
{
return TRUE;
}
}
else if ( \IPS\Settings::i()->ipb_url_filter_option == 'white' )
{
/* @note http:// is hard-coded here as we're simply validating that the URL is on the same domain, so the protocol doesn't matter for the base_url replacement */
if ( is_null( $good ) AND !preg_match( '/' . $url . '/i', str_replace( '<___base_url___>', 'http://' . parse_url( \IPS\Settings::i()->base_url, PHP_URL_HOST ), $urlToCheck ), $matches ) )
{
$good = FALSE;
break 2;
}
else
{
$good = TRUE;
break 2;
}
}
}
}
}
}
if ( $good === FALSE AND \IPS\Settings::i()->ipb_url_filter_option == 'white' )
{
return TRUE;
}
}
if ( $good === FALSE AND \IPS\Settings::i()->ipb_url_filter_option == 'white' )
{
return TRUE;
}
catch( \Exception $e ) { }
}
catch( \Exception $e ) { }
return FALSE;
}