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

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.  The following fix works for us.

In html.h, add a new lexer char type:

#define firstnamechar 128


In lexer.c, InitMap(), make ':', '_', and letters firstnamechars by
changing:

    MapStr("-.:_", namechar);
 to
    MapStr("-.", namechar);
    MapStr(":_", namechar|firstnamechar);

 and

    MapStr("abcdefghijklmnopqrstuvwxyz", lowercase|letter|namechar);
    MapStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", uppercase|letter|namechar);
 to
    MapStr("abcdefghijklmnopqrstuvwxyz",
lowercase|letter|namechar|firstnamechar);
    MapStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ",
uppercase|letter|namechar|firstnamechar);


In lexer.c, IsValidAttrName(), check for an illegal first character:

    int i = 0;      // Existing line, unchanged

    if (wstrlen(attr) > 0)
    {
        c = attr[0];
        map = MAP(c);
        if ((map & firstnamechar) == 0)
            return false;
    }

    for( i = 0; i < wstrlen(attr); i++)  // Existing line, unchanged


Thanks,
Randy

Received on Friday, 14 April 2000 17:36:19 UTC