EditorJS/BlockHandler.php
private function sanitize($rules, $blockData)
    {
        /**
         * Sanitize every key in data block
         */
        foreach ($blockData as $key => $value) {
            /**
             * PHP Array has integer keys
             */
            if (is_integer($key)) {
                $rule = $rules[BlockHandler::DEFAULT_ARRAY_KEY];
            } else {
                $rule = $rules[$key];
            }

            $rule = $this->expandToolSettings($rule);
            $elementType = $rule['type'];

            /**
             * Sanitize string with Purifier
             */
            if ($elementType == 'string') {
                $allowedTags = isset($rule['allowedTags']) ? $rule['allowedTags'] : '';
                if ($allowedTags !== '*') {
                    $blockData[$key] = $this->getPurifier($allowedTags)->purify($value);
                }
            }

            /**
             * Sanitize nested elements
             */
            if ($elementType == 'array') {
                $blockData[$key] = $this->sanitize($rule['data'], $value);
            }
        }

        return $blockData;
    }
private function sanitize($rules, $blockData)
    {
        /**
         * Sanitize every key in data block
         */
        foreach ($blockData as $key => $value) {
            /**
             * PHP Array has integer keys
             */
            if (is_integer($key)) {
                $rule = $rules[BlockHandler::DEFAULT_ARRAY_KEY];
            } else {
                $rule = $rules[$key];
            }

            $rule = $this->expandToolSettings($rule);
            $elementType = $rule['type'];

            /**
             * Sanitize string with Purifier
             */
            if ($elementType == 'string') {
                $allowedTags = isset($rule['allowedTags']) ? $rule['allowedTags'] : '';
                if ($allowedTags !== '*') {
                    $blockData[$key] = $this->getPurifier($allowedTags)->purify($value);
                }
            }

            /**
             * Sanitize nested elements
             */
            if ($elementType == 'array') {
                $blockData[$key] = $this->sanitize($rule['data'], $value);
            }
        }

        return $blockData;
    }
private function sanitize ( $ rules , $ blockData ) { /**
         * Sanitize every key in data block
         */ foreach ( $ blockData as $ key => $ value ) { /**
             * PHP Array has integer keys
             */ if ( is_integer ( $ key ) ) { $ rule = $ rules [ BlockHandler :: DEFAULT_ARRAY_KEY ] ; } else { $ rule = $ rules [ $ key ] ; } $ rule = $ this -> expandToolSettings ( $ rule ) ; $ elementType = $ rule [ 'type' ] ; /**
             * Sanitize string with Purifier
             */ if ( $ elementType == 'string' ) { $ allowedTags = isset ( $ rule [ 'allowedTags' ] ) ? $ rule [ 'allowedTags' ] : '' ; if ( $ allowedTags !== '*' ) { $ blockData [ $ key ] = $ this -> getPurifier ( $ allowedTags ) -> purify ( $ value ) ; } } /**
             * Sanitize nested elements
             */ if ( $ elementType == 'array' ) { $ blockData [ $ key ] = $ this -> sanitize ( $ rule [ 'data' ] , $ value ) ; } } return $ blockData ; }
Sanitize strings in the data block

@param array $rules
@param array $blockData

@throws EditorJSException

@return array
Sanitize strings in the data block