Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+21 -13
View File
@@ -11,36 +11,44 @@
namespace IPS\Text;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use HTMLPurifier_AttrDef;
use HTMLPurifier_AttrDef_Switch;
use HTMLPurifier_Config;
use HTMLPurifier_Context;
use function count;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* A HTMLPurifier Attribute Definition which imitates HTMLPurifier_AttrDef_Switch but allows checking if certain attributes exist
*/
class _HtmlPurifierSwitchAttrDef extends \HTMLPurifier_AttrDef_Switch
class HtmlPurifierSwitchAttrDef extends HTMLPurifier_AttrDef_Switch
{
/**
* @brief Is the attribute required
*/
public $required = FALSE;
public bool $required = FALSE;
/**
* @brief Attributes
*/
protected $attributes = array();
protected array $attributes = array();
/**
* Constructor
*
* @param string $tag The tag name to check
* @param array $attributes The attributes to check on
* @param \HTMLPurifier_AttrDef $with_tag If $tag matches and all $attributes are present, this definition will be used
* @param \HTMLPurifier_AttrDef $without_tag Otherwise, this definition will be used
* @param HTMLPurifier_AttrDef $with_tag If $tag matches and all $attributes are present, this definition will be used
* @param HTMLPurifier_AttrDef $without_tag Otherwise, this definition will be used
*/
public function __construct( $tag, $attributes, $with_tag, $without_tag )
public function __construct( string $tag, array $attributes, $with_tag, HTMLPurifier_AttrDef $without_tag )
{
$this->attributes = $attributes;
parent::__construct( $tag, $with_tag, $without_tag );
@@ -50,15 +58,15 @@ class _HtmlPurifierSwitchAttrDef extends \HTMLPurifier_AttrDef_Switch
* Validate
*
* @param string $string
* @param \HTMLPurifier_Config $config
* @param \HTMLPurifier_Context $context
* @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context
* @return bool|string
*/
public function validate( $string, $config, $context )
{
public function validate( $string, $config, $context ): bool|string
{
$token = $context->get('CurrentToken', true);
if ( \count( array_diff( $this->attributes, array_keys( $token->attr ) ) ) )
if ( count( array_diff( $this->attributes, array_keys( $token->attr ) ) ) )
{
return $this->withoutTag->validate( $string, $config, $context );
}