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;
    }