Returns information if given html attribute is valid

@param string $htmlAttribute The html attribute to verify
@return bool
431739
public static function isValidHtmlAttribute($htmlAttribute)
    {
        /*
         * Not a string?
         * Nothing to do
         */
        if (!is_string($htmlAttribute)) {
            return false;
        }

        $pattern = self::getHtmlAttributePattern();

        return (bool)preg_match($pattern, $htmlAttribute);
    }
477325
func HTMLAttribute(in string) string {
	var out = &bytes.Buffer{}
	for _, c := range in {
		if (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || (c >= 48 && c <= 57) || (c >= 44 && c <= 46) || c == 95 {
			// a-zA-Z0-9,.-_
			out.WriteRune(c)
		} else if c == 34 {
			// "
			out.WriteString("&quot;")
		} else if c == 38 {
			// &
			out.WriteString("&amp;")
		} else if c == 60 {
			// <
			out.WriteString("&lt;")
		} else if c == 62 {
			// >
			out.WriteString("&gt;")
		} else if c <= 31 && c != 9 && c != 10 && c != 13 {
			// Non-whitespace
			out.WriteString("&#xFFFD;")
		} else {
			// UTF-8
			fmt.Fprintf(out, "&#%d;", c)
		}
	}
	return out.String()
}
1161829
function hasAttribute( $attributeName )
    {
        if ( in_array( $attributeName,
                       array( 'alternative_text',
                              'original_filename',
                              'is_valid' ) ) )
            return true;

        $imageManager = eZImageManager::factory();
        if ( $imageManager->hasAlias( $attributeName ) )
            return true;
        return false;
    }
1152738
private function isLinkList(string $html): bool
    {
        if (preg_match('/<(?:ul|dl|ol)(.+?)<\/(?:ul|dl|ol)>/isu', $html, $matched)) {
            $listPart = $matched[1];
            $outside = preg_replace('/<(?:ul|dl)(.+?)<\/(?:ul|dl)>/isu', '', $html);
            $outside = preg_replace('/<.+?>/su', '', $outside);
            $outside = preg_replace('/\s+/su', ' ', $outside);
            $list = preg_split('/<li[^>]*>/u', $listPart);
            array_shift($list);

            $rate = $this->evaluateList($list);
            if ($rate == 1) {
                return false;
            }

            return strlen($outside) <= (strlen($html) / (45 / $rate));
        }

        return false;
    }
1244522
public static function validate($html)
    {
        $curlHandler = curl_init('https://validator.nu/?out=gnu');

        curl_setopt($curlHandler, CURLOPT_CUSTOMREQUEST, 'POST');
        curl_setopt($curlHandler, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $html);
        curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curlHandler, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
        curl_setopt($curlHandler, CURLOPT_HTTPHEADER, [
            'Content-type: text/html; charset=utf-8',
            'Content-Length: ' . strlen($html),
        ]);

        $result = curl_exec($curlHandler);

        if (curl_getinfo($curlHandler, CURLINFO_HTTP_CODE) !== 200) {
            throw new RuntimeException('Curl error (are you connected to Internet?): ' . curl_error($curlHandler));
        }

        return $result;
    }
571984
protected function isAttributeAuditable(string $attribute): bool
    {
        // The attribute should not be audited
        if (in_array($attribute, $this->excludedAttributes, true)) {
            return false;
        }

        // The attribute is auditable when explicitly
        // listed or when the include array is empty
        $include = $this->getAuditInclude();

        return empty($include) || in_array($attribute, $include, true);
    }
231618
protected function getAttributesAsHtml()
	{
		$htmlAttrs = '';
		
		foreach($this->attributes as $attrName => $attrValue) {
			$htmlAttrs .= ' ' . $attrName . (($attrValue === null || strlen($attrValue) === 0)?null:'="' . $attrValue . '"');
		}
		
		return $htmlAttrs;
	}
425020
private static function getAttributes($attr)
    {
        $html = "";
        foreach ($attr as $key => $value) {
            $html .= $key . '="' . $value . '" ';
        }

        return $html;
    }
989198
protected function isAttribute(string $name)
    {
        $searchParam = '_attr';
        if (mb_substr_count($name, $searchParam, 'UTF-8') > 0) {
            return str_replace($searchParam, '', $name);
        }

        return false;
    }
641540
protected function isMathML( $html ) {

		foreach ( $this->MathMLTags as $tag ) {
			if ( false !== stripos( $html, "<$tag>" ) ) {
				return true;
			}
		}

		return false;
	}
710332
private function matches($htmlErrorString, $pattern)
    {
        if ($this->simpleMatchRejection($htmlErrorString, $pattern) === false) {
            return false;
        }

        return $this->pregMatch($htmlErrorString, $pattern);
    }
895915
public function __toAttribute()
	{
		if ( $this->count() ) {
			$attr = null;

			if ( is_string( $this->attribute ) ) {
				$attr = $this->attribute;
			}
			elseif ( $this->attribute instanceof DOMAttr ) {
				$attr = $this->attribute->name;
			}

			if ( $attr ) {
				$values = htmlspecialchars((string) $this, ENT_QUOTES, ini_get('default_charset'), false);
				return sprintf('%1$s="%2$s"', $attr, $values);
			}
		}

		return '';
	}
944926
public function jQueryValidationEngine($html)
	{
		$validation = array();
		if($this->required===true)
		{
			$validation[] = 'required';
		}
		if(isset($this->min) and $this->min>0)
		{
			$validation[] = "minSize[{$this->min}]";
		}
		if(isset($this->max) and $this->max>0)
		{
			$validation[] = "maxSize[{$this->max}]";
		}
		if(isset($this->regex))
		{
			$validation[] = "custom[el{$this->id}]";
			$regex = json_encode($this->regex);
			$html .= <<<HERE
<script type="text/javascript">
//<![CDATA[
(function($){
	if($ && $.validationEngineLanguage)
	{
		$.validationEngineLanguage.allRules.el{$this->id} = {};
		$.validationEngineLanguage.allRules.el{$this->id}.regex = new RegExp({$regex});
	}
})(jQuery);
//]]>
</script>
HERE;
		}
		if(!empty($validation))
			$html = str_replace("<input", "<input class=\"validate[".implode(',', $validation)."]\"", $html);
		return $html;
	}
740652
public function hasAttribute($name)
    {
        if(strlen($name) < 1)
        {
            throw new HTMLTagException("Attribute name is empty");
        }

        return (isset($this->tag_attributes[strtolower($name)])) ? true : false;
    }
1282640
public function setHtml($Html)
    {
        if (! is_object($Html) || ! $Html instanceof HtmlObject) {
            throw new \InvalidArgumentException(
                'The HTML Object must be a valid HTML Object'
            );
        }
        $this->Html = $Html;

        return true;
    }
646916
protected function isAttributeBoolean(ModelAttributeData $attribute)
    {
        if ($attribute->cast == AttributeCast::BOOLEAN) {
            return true;
        }

        return $attribute->type === 'tinyint' && $attribute->length === 1;
    }
693955
static function htmlAttributes(array $attributes = array()) {
    foreach ($attributes as $attribute => &$data) {
      $data = implode(' ', (array) $data);
      $data = $attribute . '="' . self::checkPlain($data) . '"';
    }
    return $attributes ? ' ' . implode(' ', $attributes) : '';
  }