Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.64.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : sanitize.php
<?php

trait Brizy_Editor_Trait_Sanitize {

	public function sanitizeUid($uid) {
		// eliminate anything that is not a letter, digit, “_”, “-”, “.” —or any run of two-or-more dots
		$auid =  preg_replace("/(?:[^\w.\-]|\.{2,})+/u", "", $uid);

		return $auid;
	}

	public function sanitizeHtml( $html ) {
		if ( current_user_can( 'unfiltered_html' ) ) {
			return $html;
		}
		add_filter( 'safe_style_css', function ( $styles ) {
			$styles[] = 'rgba';
			$styles[] = 'rgb';
			$styles[] = 'var';
			$styles[] = 'color';
			$styles[] = 'linear-gradient';
			$styles[] = 'display';

			return $styles;
		} );
		add_filter( 'safecss_filter_attr_allow_css', function ( $css, $value ) {
			// we may need to add more methods here
			$preg_match = preg_match( '/(rgba?|hsla?|calc|opacity|blur)\(.*?\)/i', $value );

			return $preg_match;
		}, 10, 2 );

		$html = wp_kses_post( $html );
		return $html;
	}

	public function sanitizeJson( $data ) {
		if ( current_user_can( 'unfiltered_html' ) ) {
			return $data;
		}

		if ( ! $dataDecoded = json_decode( $data, true ) ) {
			return $data;
		}
		add_filter( 'safe_style_css', function ( $styles ) {
			$styles[] = 'rgba';
			$styles[] = 'rgb';
			$styles[] = 'var';
			$styles[] = 'color';
			$styles[] = 'linear-gradient';
			$styles[] = 'display';

			return $styles;
		} );
		add_filter( 'safecss_filter_attr_allow_css', function ( $css, $value ) {
			// we may need to add more methods here
			$preg_match = preg_match( '/(rgba?|hsla?|calc|opacity|blur)\(.*?\)/i', $value );

			return $preg_match;
		}, 10, 2 );
		$dataDecoded = wp_kses_post_deep( $dataDecoded );

		//$dataDecoded = $this->escapeJsonValues( $dataDecoded );
		$data = json_encode( $dataDecoded );
		$data = preg_replace( '/javascript:.*?"/', '"', $data );
		$data = preg_replace( '/javascript%3A.*?%22/', '%22', $data );
		$data = preg_replace( '/(on(click|mouseover|keydown|keyup|change|submit|load|error|focus|blur|select|dblclick))\s*[:=]\s*(\\\"|\\\')(.*?)(\3)/i', '', $data );

		//remove_filter( 'safecss_filter_attr_allow_css', '__return_true' );
		return $data;
	}

}
© 2025 XylotrechusZ