Re: Bug and suggested fix: Tidy lets attribute names begin with '-', '.', or a digit

On Fri, 14 Apr 2000, Randy Waki wrote:

> 13-Jan-2000 Tidy doesn't complain about illegal attribute names
> beginning with '-', '.', or a digit.  The problem is in
> IsValidAttrName() in lexer.c where the first character isn't being
> distinguished.

Thanks for spotting this and for the patch. I will now use:

/* attr must be non-null */
Bool IsValidAttrName( char *attr)
{
    uint map, c;
    int i;

    /* first character should be a letter */
    c = attr[0];
    map = MAP(c);

    if (!(map & letter))
        return no;

    /* remaining characters should be namechars */
    for( i = 1; i < wstrlen(attr); i++)
    {
        c = attr[i];
        map = MAP(c);

        if (map & namechar)
            continue;

        return no;
    }

    return yes;
}

Regards,

-- Dave Raggett <dsr@w3.org> http://www.w3.org/People/Raggett
tel/fax: +44 122 578 3011 (or 2521) +44 778 532 0444 (mobile)
World Wide Web Consortium (on assignment from HP Labs)

Received on Friday, 21 April 2000 07:34:08 UTC