private function cleanAttrValue(DOMAttr $domAttr)
    {
        $attrName = strtolower($domAttr->name);
        if ($attrName === 'style' && !empty($this->config->WhiteListStyle)) {
            $styles = explode(';', $domAttr->value);
            foreach ($styles as $key => &$subStyle) {
                $subStyle = array_map("trim", explode(':', strtolower($subStyle), 2));
                if (empty($subStyle[0]) || !in_array($subStyle[0], $this->config->WhiteListStyle)) {
                    unset($styles[$key]);
                }
            }
            $implodeFunc = function ($styleSheet) {
                return implode(':', $styleSheet);
            };
            $domAttr->ownerElement->setAttribute($attrName, implode(';', array_map($implodeFunc, $styles)) . ';');
        }
        if ($attrName === 'class' && !empty($this->config->WhiteListCssClass)) {
            $domAttr->ownerElement->setAttribute($attrName, implode(' ', array_intersect(preg_split('/\s+/', $domAttr->value), $this->config->WhiteListCssClass)));
        }
        if ($attrName === 'src' || $attrName === 'href') {
            if (strtolower(parse_url($domAttr->value, PHP_URL_SCHEME)) === 'javascript') {
                $domAttr->ownerElement->removeAttribute($attrName);
            } else {
                $domAttr->ownerElement->setAttribute($attrName, filter_var($domAttr->value, FILTER_SANITIZE_URL));
            }
        }
    }
private function cleanAttrValue(DOMAttr $domAttr)
    {
        $attrName = strtolower($domAttr->name);
        if ($attrName === 'style' && !empty($this->config->WhiteListStyle)) {
            $styles = explode(';', $domAttr->value);
            foreach ($styles as $key => &$subStyle) {
                $subStyle = array_map("trim", explode(':', strtolower($subStyle), 2));
                if (empty($subStyle[0]) || !in_array($subStyle[0], $this->config->WhiteListStyle)) {
                    unset($styles[$key]);
                }
            }
            $implodeFunc = function ($styleSheet) {
                return implode(':', $styleSheet);
            };
            $domAttr->ownerElement->setAttribute($attrName, implode(';', array_map($implodeFunc, $styles)) . ';');
        }
        if ($attrName === 'class' && !empty($this->config->WhiteListCssClass)) {
            $domAttr->ownerElement->setAttribute($attrName, implode(' ', array_intersect(preg_split('/\s+/', $domAttr->value), $this->config->WhiteListCssClass)));
        }
        if ($attrName === 'src' || $attrName === 'href') {
            if (strtolower(parse_url($domAttr->value, PHP_URL_SCHEME)) === 'javascript') {
                $domAttr->ownerElement->removeAttribute($attrName);
            } else {
                $domAttr->ownerElement->setAttribute($attrName, filter_var($domAttr->value, FILTER_SANITIZE_URL));
            }
        }
    }
private function cleanAttrValue ( DOMAttr $ domAttr ) { $ attrName = strtolower ( $ domAttr -> name ) ; if ( $ attrName === 'style' && ! empty ( $ this -> config -> WhiteListStyle ) ) { $ styles = explode ( ';' , $ domAttr -> value ) ; foreach ( $ styles as $ key => & $ subStyle ) { $ subStyle = array_map ( "trim" , explode ( ':' , strtolower ( $ subStyle ) , 2 ) ) ; if ( empty ( $ subStyle [ 0 ] ) || ! in_array ( $ subStyle [ 0 ] , $ this -> config -> WhiteListStyle ) ) { unset ( $ styles [ $ key ] ) ; } } $ implodeFunc = function ( $ styleSheet ) { return implode ( ':' , $ styleSheet ) ; } ; $ domAttr -> ownerElement -> setAttribute ( $ attrName , implode ( ';' , array_map ( $ implodeFunc , $ styles ) ) . ';' ) ; } if ( $ attrName === 'class' && ! empty ( $ this -> config -> WhiteListCssClass ) ) { $ domAttr -> ownerElement -> setAttribute ( $ attrName , implode ( ' ' , array_intersect ( preg_split ( '/\s+/' , $ domAttr -> value ) , $ this -> config -> WhiteListCssClass ) ) ) ; } if ( $ attrName === 'src' || $ attrName === 'href' ) { if ( strtolower ( parse_url ( $ domAttr -> value , PHP_URL_SCHEME ) ) === 'javascript' ) { $ domAttr -> ownerElement -> removeAttribute ( $ attrName ) ; } else { $ domAttr -> ownerElement -> setAttribute ( $ attrName , filter_var ( $ domAttr -> value , FILTER_SANITIZE_URL ) ) ; } } }
Clean the value of the attribute
@param DOMAttr $domAttr
Clean the value of the attribute