@param string $originalHtml
@param array  $attributesFilters

@return null|string|string[]
342139
public function transformHtml($originalHtml, array $attributesFilters = [])
    {
        // regex is used because:
        // 1 - preserves the original html, that would otherwise change when converted to a DOM abstraction
        // 2 - works with invalid surrounding html
        return preg_replace_callback('/(<img[^>]+>)/i', function ($matches) use ($attributesFilters) {
            try {
                return $this->imageTransformer->transformImage($matches[0], $attributesFilters);
            } catch (\Exception $e) {
                if ($e instanceof ResolutionException || $e instanceof TransformationException) {
                    return $matches[0];
                }
                throw $e;
            }
        }, $originalHtml);
    }
515505
public function getAttributesHTML($attributes = null)
    {
        // Initialise:
        
        $remove = [];
        
        // Detect Excluded Attributes:
        
        if (is_string($attributes)) {
            $remove = func_get_args();
        }
        
        // Detect Passed Attributes:
        
        if (!$attributes || is_string($attributes)) {
            $attributes = $this->getAttributes();
        }
        
        // Ensure Array Data Type:
        
        $attributes = (array) $attributes;
        
        // Remove Excluded Attributes:
        
        if (!empty($remove)) {
            $attributes = array_diff_key($attributes, array_flip($remove));
        }
        
        // Answer Markup:
        
        return ViewTools::singleton()->getAttributesHTML($attributes);
    }
686672
protected function sourceParsedownElement(array $attributes, $reset = true)
    {
        empty($attributes['src']) && $attributes['src'] = $this->url($reset);

        return ['name' => 'img', 'attributes' => $attributes];
    }
1258356
private function parse_attribs($attribs)
	{
		$ret     = array('default' => null);
		$attribs = trim($attribs);

		if($attribs == '')
			return $ret;

		// if this tag only has one = then there is only one attribute
		// so add it all to default
		if($attribs[0] == '=' && strrpos($attribs, '=') === 0)
			$ret['default'] = htmlentities(substr($attribs, 1), ENT_QUOTES | ENT_IGNORE, "UTF-8");
		else
		{
			preg_match_all('/(\S+)=((?:(?:(["\'])(?:\\\3|[^\3])*?\3))|(?:[^\'"\s]+))/',
				$attribs,
				$matches,
				PREG_SET_ORDER);

			foreach($matches as $match)
				$ret[$match[1]] = htmlentities($match[2], ENT_QUOTES | ENT_IGNORE, "UTF-8");
		}

		return $ret;
	}
83492
private static function _cleanHTML(DOMNode $Node, array $filters){

		$node_contents = '';
		$tag_name = '';

		if(isset($Node->tagName)){

			$tag_name = strtolower(trim($Node->tagName));
		}

		// Drop tags

		assert('isset($filters[\'tags_drop\']) && is_array($filters[\'tags_drop\'])');
		if(!isset($filters['tags_drop']) || !is_array($filters['tags_drop'])){

			$filters['tags_drop'] = [];
		}

		if($Node instanceof DOMComment || in_array($tag_name, $filters['tags_drop'])){

			return '';
		}

		// Clean node contents

		if(!isset($Node->childNodes) || $Node->childNodes->length == 0){

			// As no charset conversion is needed, nodeValue can be directly used

			$node_contents = html_entity_decode($Node->nodeValue, ENT_QUOTES, DEFAULT_CHARSET);

			// Reduce every possible combination of whitespaces to a single space-character

			$node_contents = preg_replace('/\s+/', ' ', $node_contents);

			// Reapply HTML entities

			$node_contents = htmlentities($node_contents, ENT_QUOTES, DEFAULT_CHARSET);
		}
		else{

			foreach($Node->childNodes as $Child){

				$node_contents .= self::_cleanHTML($Child, $filters);
			}
		}

		// Nameless and disallowed nodes (return content only, no tags)

		assert('isset($filters[\'tags\']) && is_array($filters[\'tags\'])');
		if(!isset($filters['tags']) || !is_array($filters['tags'])){

			$filters['tags'] = [];
		}

		if($tag_name == '' || !in_array($tag_name, $filters['tags'])){

			return $node_contents;
		}

		// Allowed nodes (return tag and content)

		else{

			$node_attributes = self::_cleanAttributes($Node, $filters);

			// If (after filtering) "a" or "img" elements have no attributes, discard them

			if($node_attributes == '' && ($tag_name == 'a' || $tag_name == 'img')){

				return $node_contents;
			}

			switch($tag_name){

				// Empty elements (c.q. self-closing)

				case 'br':
				case 'hr':
				case 'input':
				case 'img':

					return "<$tag_name$node_attributes>";

				break;

				// Elements with content

				default:

					// Empty "a" elements (c.q. page anchors) are allowed

					if(trim($node_contents) == '' && $tag_name != 'a') return '';

					return "<$tag_name$node_attributes>$node_contents</$tag_name>";
			}
		}
	}
1128402
protected function searchNodes(Filter\AbstractFilter $filter, $attributes = null, $searchScope = Connection::SEARCH_SCOPE_SUB, $maxResults = 0, $maxFilterTime = 0)
    {
        if ($attributes === null) {
            $attributes = $this->getSearchAttributes();
        }

        return $this->connection->search(
            $filter,
            $this->getSearchBaseDn(),
            $searchScope,
            $attributes,
            null,
            $this->getNodeCollectionClass(),
            $maxResults,
            $maxFilterTime
        );
    }
950770
public function generateImage($originalUrl, array $attributesFilters)
    {
        if (empty($attributesFilters)) {
            throw new \InvalidArgumentException('Please provide at least one key for attribute generation (e.g. \'src\') ');
        }

        $image = (new \DOMDocument())->createElement('img');

        try {
            foreach ($attributesFilters as $attributeName => $filters) {
                $attributeValue = $this->attributeGenerator->generateAttributeValue($originalUrl, $filters);
                if ('' !== $attributeValue) {
                    $image->setAttribute($attributeName, $attributeValue);
                }
            }
        } catch (ResolutionException $e) {
            $image->setAttribute('src', $originalUrl);
        }

        return $this->renderer->render($image);
    }
49089
private static function _parse_form_attributes($attributes, $default)
    {
        if (is_array($attributes)) {
            foreach ($default as $key => $val) {
                if (isset($attributes[$key])) {
                    $default[$key] = $attributes[$key];
                    unset($attributes[$key]);
                }
            }

            if (count($attributes) > 0) {
                $default = array_merge($default, $attributes);
            }
        }

        $att = '';

        foreach ($default as $key => $val) {
            if ($key == 'value') {
                $val = self::form_prep($val, $default['name']);
            }

            $att .= $key . '="' . $val . '" ';
        }

        return $att;
    }
874841
protected function createHTMLFilter(): HTMLFilter
    {
        $filter = new HTMLFilter(
            $this->source ? static::SOURCE_WHITELIST : static::DESCRIPTION_WHITELIST,
            ['before' => $this->source ? null : function (\DOMElement $body): void {
                foreach (['img', 'audio', 'video'] as $elementName) {
                    foreach ($body->getElementsByTagName($elementName) as $element) {
                        if ($element->hasAttribute('src')) {
                            $fileLocationValidator = new \esperecyan\dictionary_php\validator\FileLocationValidator(
                                $elementName === 'img' ? 'image' : $elementName,
                                $this->filenames
                            );
                            $fileLocationValidator->setLogger($this);
                            $element
                                ->setAttribute('src', $fileLocationValidator->correct($element->getAttribute('src')));
                        }
                    }
                }
            }]
        );
        $filter->setLogger($this);
        return $filter;
    }
342637
public function generateAttributeValue($originalUrl, $filtersOrConfigurationKey = [], array $extraFilters = [])
    {
        $filters = $this->prepareFilterParams($filtersOrConfigurationKey, $extraFilters);

        return $this->attributeGenerator->generateAttributeValue($originalUrl, $filters);
    }
289911
static function createExtendedAttributeFilterSQLStrings( &$extendedAttributeFilter )
    {
        $filter = array( 'tables'   => '',
                         'joins'    => '',
                         'columns'  => '',
                         'group_by' => '' );

        if ( $extendedAttributeFilter and count( $extendedAttributeFilter ) > 1 )
        {
            $extendedAttributeFilterID      = $extendedAttributeFilter['id'];
            $extendedAttributeFilterParams  = $extendedAttributeFilter['params'];
            $filterINI                      = eZINI::instance( 'extendedattributefilter.ini' );

            if ( !$filterINI->hasGroup( $extendedAttributeFilterID ) )
            {
                eZDebug::writeError( "Unable to find configuration for the extended attribute filter '$extendedAttributeFilterID', the filter will be ignored", __METHOD__ );
                return $filter;
            }

            $filterClassName    = $filterINI->variable( $extendedAttributeFilterID, 'ClassName' );
            $filterMethodName   = $filterINI->variable( $extendedAttributeFilterID, 'MethodName' );

            if ( $filterINI->hasVariable( $extendedAttributeFilterID, 'FileName' ) )
            {
                $filterFile = $filterINI->variable( $extendedAttributeFilterID, 'FileName' );

                if ( $filterINI->hasVariable( $extendedAttributeFilterID, 'ExtensionName' ) )
                {
                    $extensionName = $filterINI->variable( $extendedAttributeFilterID, 'ExtensionName' );
                    include_once( eZExtension::baseDirectory() . "/$extensionName/$filterFile" );
                }
                else
                {
                    include_once( $filterFile );
                }
            }

            if ( !class_exists( $filterClassName, true ) )
            {
                eZDebug::writeError( "Unable to find the PHP class '$filterClassName' associated with the extended attribute filter '$extendedAttributeFilterID', the filter will be ignored", __METHOD__ );
                return $filter;
            }

            $classObject        = new $filterClassName();
            $parameterArray     = array( $extendedAttributeFilterParams );

            $sqlResult          = call_user_func_array( array( $classObject, $filterMethodName ), $parameterArray );

            $filter['tables']   = $sqlResult['tables'];
            $filter['joins']    = $sqlResult['joins'];
            $filter['columns']  = isset( $sqlResult['columns'] ) ? $sqlResult['columns'] : '';

            if( isset( $sqlResult['group_by'] ) )
                $filter['group_by'] =  $sqlResult['group_by'];
        }

        return $filter;
    }
989868
private String filterAttributes(String html) {
		String filteredHtml = html;
		for (String attribute : this.filterAttributes) {
			String regex = "\\s" + attribute + "=\"[^\"]*\"";
			Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
			Matcher m = p.matcher(html);
			filteredHtml = m.replaceAll("");
		}
		return filteredHtml;
	}
970309
public function generateUrl($originalUrl, $filtersOrConfigurationKey = [], array $extraFilters = [])
    {
        $filters = $this->prepareFilterParams($filtersOrConfigurationKey, $extraFilters);

        return $this->urlGenerator->generateUrl($originalUrl, $filters);
    }
510300
public function getFiltered($page, $numRows, $sortAttr, $sortOrder, $searchAttr, $searchValue, $richFilters = [])
    {
        $query = $this->prepareQuery();

        $query = $this->richFiltersOnQuery($query, $richFilters);

        if ($sortAttr && $sortOrder && $this->inScope($sortAttr)) {
            $scope = $this->getScope($sortAttr);
            $query = $query->orderBy($scope, $sortOrder);
        }

        if ($searchAttr && $searchValue && $this->inScope($searchAttr)) {
            $scope = $this->getScope($searchAttr);
            $query = $query->where($scope, 'like', '%' . $searchValue . '%');
        }

        $collection = $query->get();

        $collection = $this->addPermissions($collection);

        $collection = $this->formatCollection($collection);

        $collection = $collection->each(function ($model) {
            $model = $this->formatModel($model);
        });

        if ($sortAttr && $sortOrder && ! $this->inScope($sortAttr)) {
            $collection = $sortOrder == 'asc'
                ? $collection->sortBy($sortAttr)
                : $collection->sortByDesc($sortAttr);
        }

        $collection = $this->richFiltersOnCollection($collection, $richFilters);

        if ($searchAttr && $searchValue && ! $this->inScope($searchAttr)) {
            $collection = $collection->filter(function ($model) use ($searchAttr, $searchValue) {
                $value = (string) $model->$searchAttr;
                $value = strtolower($value);
                $search = strtolower($searchValue);
                return strpos($value, $search) !== false;
            });
        }

        if ($page && $numRows) {
            $toSkip = ($page - 1) * $numRows;
            $count = $collection->count();
            $collection = $collection->take(- ($count - $toSkip))->take($numRows);
        } else if ($numRows)
            $collection = $collection->take($numRows);

        return collect(array_values($collection->toArray()));
    }
335775
public static filterhtmlinjectionvariable[] get_filtered(nitro_service service, String filter) throws Exception{
		filterhtmlinjectionvariable obj = new filterhtmlinjectionvariable();
		options option = new options();
		option.set_filter(filter);
		filterhtmlinjectionvariable[] response = (filterhtmlinjectionvariable[]) obj.getfiltered(service, option);
		return response;
	}
1107380
protected function checkAttributeFilters(array $attributes)
	{
		foreach ($attributes as $attrConfig)
		{
			if (empty($attrConfig['filterChain']))
			{
				continue;
			}
			foreach ($attrConfig['filterChain'] as $filter)
			{
				if (substr($filter, 0, 1) !== '#' && !in_array($filter, $this->allowedFilters, true))
				{
					throw new RuntimeException("Filter '$filter' is not allowed in media sites");
				}
			}
		}
	}
239676
protected function getFilterParts($facetConfiguration, $facetName, $filterValues)
    {
        $filterParts = [];

        $type = isset($facetConfiguration['type']) ? $facetConfiguration['type'] : 'options';
        $filterEncoder = $this->facetRegistry->getPackage($type)->getUrlDecoder();

        if (is_null($filterEncoder)) {
            throw new \InvalidArgumentException('No encoder configured for facet ' . htmlspecialchars($facetName));
        }

        foreach ($filterValues as $filterValue) {
            $filterOptions = $facetConfiguration[$facetConfiguration['type'] . '.'];
            if (empty($filterOptions)) {
                $filterOptions = [];
            }

            $filterValue = $filterEncoder->decode($filterValue, $filterOptions);
            $filterParts[] = $facetConfiguration['field'] . ':' . $filterValue;
        }

        return $filterParts;
    }