Function to determine if contents of an attribute are safe

@param   array  $attrSubSet  A 2 element array for attribute's name, value

@return  boolean  True if bad code is detected

@since   1.0
196551
public static function checkAttribute($attrSubSet)
	{
		$attrSubSet[0] = strtolower($attrSubSet[0]);
		$attrSubSet[1] = strtolower($attrSubSet[1]);

		return (((strpos($attrSubSet[1], 'expression') !== false) && ($attrSubSet[0]) == 'style') || (strpos($attrSubSet[1], 'javascript:') !== false) ||
			(strpos($attrSubSet[1], 'behaviour:') !== false) || (strpos($attrSubSet[1], 'vbscript:') !== false) ||
			(strpos($attrSubSet[1], 'mocha:') !== false) || (strpos($attrSubSet[1], 'livescript:') !== false));
	}
365327
protected function cleanAttributes($attrSet)
    {
        $newSet = [];

        $count = count($attrSet);

        // Iterate through attribute pairs
        for ($i = 0; $i < $count; $i++) {
            // Skip blank spaces
            if (!$attrSet[$i]) {
                continue;
            }

            // Split into name/value pairs
            $attrSubSet = explode('=', trim($attrSet[$i]), 2);

            // Take the last attribute in case there is an attribute with no value
            $attrSubSet_0 = explode(' ', trim($attrSubSet[0]));
            $attrSubSet[0] = array_pop($attrSubSet_0);

            // Remove all "non-regular" attribute names
            // AND blacklisted attributes
            if ((!preg_match('/[a-z]*$/i', $attrSubSet[0]))
                || ($this->xssAuto && (in_array(strtolower($attrSubSet[0]), $this->attrBlacklist, true)
                        || (strpos($attrSubSet[0], 'on') === 0)))) {
                continue;
            }

            // XSS attribute value filtering
            if (isset($attrSubSet[1])) {
                // Trim leading and trailing spaces
                $attrSubSet[1] = trim($attrSubSet[1]);

                // Strips unicode, hex, etc
                $attrSubSet[1] = str_replace('&#', '', $attrSubSet[1]);

                // Strip normal newline within attr value
                $attrSubSet[1] = preg_replace('/[\n\r]/', '', $attrSubSet[1]);

                // Strip double quotes
                $attrSubSet[1] = str_replace('"', '', $attrSubSet[1]);

                // Convert single quotes from either side to doubles
                // (Single quotes shouldn't be used to pad attr values)
                if ((strpos($attrSubSet[1], "'") === 0)
                    && (substr($attrSubSet[1], strlen($attrSubSet[1]) - 1, 1) === "'")) {
                    $attrSubSet[1] = substr($attrSubSet[1], 1, -1);
                }

                // Strip slashes
                $attrSubSet[1] = stripslashes($attrSubSet[1]);
            } else {
                continue;
            }

            // Autostrip script tags
            if (self::isBadAttribute($attrSubSet)) {
                continue;
            }

            // Is our attribute in the user input array?
            $attrFound = in_array(strtolower($attrSubSet[0]), $this->attrArray, true);

            // If the tag is allowed lets keep it
            if ((!$attrFound && $this->attrMethod) || ($attrFound && !$this->attrMethod)) {
                // Does the attribute have a value?
                if (empty($attrSubSet[1]) === false) {
                    $newSet[] = $attrSubSet[0] . '="' . $attrSubSet[1] . '"';
                } elseif ($attrSubSet[1] === "0") {
                    // Special Case
                    // Is the value 0?
                    $newSet[] = $attrSubSet[0] . '="0"';
                } else {
                    // Leave empty attributes alone
                    $newSet[] = $attrSubSet[0] . '=""';
                }
            }
        }

        return $newSet;
    }
466778
public static function areAttributesValid($attributes)
    {
        if (!is_array($attributes)) {
            return false;
        }

        if (empty($attributes)) {
            return true;
        }
        // At least one key string to be an associative array.
        return count(array_filter(array_keys($attributes), 'is_string')) > 0;
    }
254792
public function containsSubset(Set $set)
    {
        if (count($set->getValue()) > count($this->getValue())) {
            return false;
        }

        return array_intersect($set->getValue(), $this->getValue()) == $set->getValue();
    }
356889
public function prepare(&$attrs)
    {
        parent::prepare($attrs);

        $attrs['max'] = $this->getAttribute('max');
        $attrs['min'] = $this->getAttribute('min');
        $attrs['step'] = $this->getAttribute('step');
        $attrs['patten'] = $this->getAttribute('pattern');
    }
509225
protected function attribute(&$attributes) {
        $tok = $this->scanner->current();
        if ($tok == '/' || $tok == '>' || $tok === false) {
            return false;
        }

        if ($tok == '<') {
            $this->parseError("Unexepcted '<' inside of attributes list.");
            // Push the < back onto the stack.
            $this->scanner->unconsume();
            // Let the caller figure out how to handle this.
            throw new HTML5_Parser_Exception("Start tag inside of attribute.");
        }

        $name = strtolower($this->scanner->charsUntil("/>=\n\f\t "));

        if (strlen($name) == 0) {
            $this->parseError("Expected an attribute name, got %s.", $this->scanner->current());
            // Really, only '=' can be the char here. Everything else gets absorbed
            // under one rule or another.
            $name = $this->scanner->current();
            $this->scanner->next();
        }

        $isValidAttribute = true;
        // Attribute names can contain most Unicode characters for HTML5.
        // But method "DOMElement::setAttribute" is throwing exception
        // because of it's own internal restriction so these have to be filtered.
        // see issue #23: https://github.com/Masterminds/html5-php/issues/23
        // and http://www.w3.org/TR/2011/WD-html5-20110525/syntax.html#syntax-attribute-name
        if (preg_match("/[\x1-\x2C\\/\x3B-\x40\x5B-\x5E\x60\x7B-\x7F]/u", $name)) {
            $this->parseError("Unexpected characters in attribute name: %s", $name);
            $isValidAttribute = false;
        }         // There is no limitation for 1st character in HTML5.
        // But method "DOMElement::setAttribute" is throwing exception for the
        // characters below so they have to be filtered.
        // see issue #23: https://github.com/Masterminds/html5-php/issues/23
        // and http://www.w3.org/TR/2011/WD-html5-20110525/syntax.html#syntax-attribute-name
        else
        if (preg_match("/^[0-9.-]/u", $name)) {
            $this->parseError("Unexpected character at the begining of attribute name: %s", $name);
            $isValidAttribute = false;
        }
        // 8.1.2.3
        $this->scanner->whitespace();

        $val = $this->attributeValue();
        if ($isValidAttribute) {
            $attributes[$name] = $val;
        }
        return true;
    }
384889
protected function addAttrRecurses($key, array $attr)
    {
        if (isset($this->form[ $key ])) {
            $this->form[ $key ][ 'attr' ] = $this->merge_attr($this->form[ $key ][ 'attr' ], $attr);

            return true;
        }

        foreach ($this->form as $input) {
            if ($input[ 'type' ] != 'group') {
                continue;
            }

            if ($input[ 'subform' ]->addAttrRecurses($key, $attr)) {
                return true;
            }
        }

        return false;
    }
1213849
public function __isset($name)
    {
        return $this->dirtyAttributeExists($name) || ($this->propertyExists($name)
            && $this->attributeExists($name));
    }
661215
public function isLinkedToHisParentBy(ContentSet $contentset = null)
    {
        if (
            null !== $contentset &&
            true === array_key_exists($contentset->getUid(), $this->getInheritedZones())
        ) {
            return true;
        }

        return false;
    }
1315852
public function setAttrs($attrs)
	{
		if(is_array($attrs))
		{
			$this->data = $attrs;
		}
		foreach($this->attrsDefault as $key=>$value)
		{
			if(null===$this->get($key,null))
			{
				$this->set($key,$value);
			}
		}
	}
62955
protected function checkAttribute(DOMNode $node, Tag $tag, $attrName)
	{
		// Test whether the attribute exists
		if (!isset($tag->attributes[$attrName]))
		{
			if ($this->ignoreUnknownAttributes)
			{
				return;
			}

			throw new UnsafeTemplateException("Cannot assess the safety of unknown attribute '" . $attrName . "'", $node);
		}

		// Test whether the attribute is safe to be used in this content type
		if (!$this->tagFiltersAttributes($tag) || !$this->isSafe($tag->attributes[$attrName]))
		{
			throw new UnsafeTemplateException("Attribute '" . $attrName . "' is not properly sanitized to be used in this context", $node);
		}
	}
714843
public function attr()
    {
        $args = func_get_args();

        if (isset($args[0]) && is_array($args[0])) {
            $this->attributes = array_merge($this->attributes, $args[0]);

            return $this;
        } elseif (isset($args[0]) && isset($args[1])) {
            $this->attributes[$args[0]] = $args[1];

            return $this;
        } elseif (isset($args[0])) {
            return isset($this->attributes[$args[0]]) ? $this->attributes[$args[0]] : null;
        }

        return $this->attributes;
    }
414319
protected function addAttribute(Tag $tag, $attrName)
	{
		$isUrl = false;
		$exprs = [];
		foreach ($this->captures as $key => $capture)
		{
			if ($capture['name'] !== $attrName)
			{
				continue;
			}
			$exprs[] = $capture['expr'];
			if (isset($this->references['asUrl'][$key]))
			{
				$isUrl = true;
			}
		}
		$exprs = array_unique($exprs);

		$regexp = $this->delimiter . '^';
		$regexp .= (count($exprs) === 1) ? $exprs[0] : '(?:' . implode('|', $exprs) . ')';
		$regexp .= '$' . $this->delimiter . 'D' . $this->modifiers;

		$attribute = $tag->attributes->add($attrName);

		$filter = $this->configurator->attributeFilters['#regexp'];
		$filter->setRegexp($regexp);
		$attribute->filterChain[] = $filter;

		if ($isUrl)
		{
			$filter = $this->configurator->attributeFilters['#url'];
			$attribute->filterChain[] = $filter;
		}
	}
526771
public void setAttributeSet(ElemAttributeSet attrSet)
  {

    if (null == m_attributeSets)
    {
      m_attributeSets = new Vector();
    }

    m_attributeSets.addElement(attrSet);
  }
906936
public function usesAttributesArray(): bool
    {
        if ($this->arrayName === null) {
            return false;
        }

        if ($this->attributes === null) {
            return false;
        }

        return true;
    }
1246312
protected function validate()
    {
        foreach ($this->_requiredAttr as $attr) {
            if (is_array($attr)) {
                $valid = false;
                foreach ($attr as $sub) {
                    if (!is_null($this->$sub)) {
                        $valid = true;
                        break;
                    }
                }
                if (!$valid) {
                    return false;
                }
            } elseif (is_null($this->$attr)) {
                return false;
            }
        }
        return true;
    }
1169359
protected function checkAttributes(DOMElement $embed)
	{
		$settingName = strtolower($this->settingName);
		$useDefault  = true;
		foreach ($embed->attributes as $attribute)
		{
			$attrName = strtolower($attribute->name);
			if ($attrName === $settingName)
			{
				$this->checkSetting($attribute, $attribute->value);
				$useDefault = false;
			}
		}
		if ($useDefault)
		{
			$this->checkSetting($embed, $this->defaultSetting);
		}
	}