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

On Fri, 21 Apr 2000, Dave Raggett wrote:
>
> 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;
> }

Thanks, Dave.

For my own edification, I assume that checking for letters only is OK
because HTML does not define any attribute names beginning with '_' or ':'
(which are allowed by XML and I assume SGML).

Randy

Received on Friday, 21 April 2000 12:05:07 UTC